UNPKG

@valkyriestudios/validator

Version:

A lightweight configurable javascript validator

13 lines (12 loc) 401 B
const ISBN_10_RGX = /^(?:\d{9}X|\d{10})$/; const ISBN_13_RGX = /^(?:\d{13})$/; function vISBN10(val) { return typeof val === 'string' && ISBN_10_RGX.test(val); } function vISBN13(val) { return typeof val === 'string' && ISBN_13_RGX.test(val); } function vISBN(val) { return typeof val === 'string' && (ISBN_10_RGX.test(val) || ISBN_13_RGX.test(val)); } export { vISBN10, vISBN13, vISBN };