How to use the isISBN function from validator

Find comprehensive JavaScript validator.isISBN code examples handpicked from public code repositorys.

123
124
125
126
127
128
129
130
131
132
},
date: function(x) {
  check(x, "a date", validator.isDate(x));
},
isbn: function(x) {
  check(x, "a book number", validator.isISBN(x));
},
json: function(x) {
  check(x, "a JSON object", validator.isJSON(x));
}
fork icon2
star icon4
watch icon0

239
240
241
242
243
244
245
246
247
248
};

validator.isISBN = function (str, version) {
    version = validator.toString(version);
    if (!version) {
        return validator.isISBN(str, 10) || validator.isISBN(str, 13);
    }
    var sanitized = str.replace(/[\s-]+/g, '')
      , checksum = 0, i;
    if (version === '10') {
fork icon2
star icon3
watch icon4

155
156
157
158
159
160
161
162
163
164
  }
  return true;
},
isISBN: function(rule, value) {
  if (rule) {
    return validator.isISBN(value);
  }
  return true;
},
isJSON: function(rule, value) {
fork icon0
star icon2
watch icon2

+ 5 other calls in file

75
76
77
78
79
80
81
82
83
84
isIP: function (str, version) {
  return validator.isIP(str, typeof version !== 'boolean' ? version : undefined);
},
// isISBN(str [, version]) - check if the string is an ISBN (version 10 or 13).
isISBN: function (str, version) {
  return validator.isISBN(str, typeof version !== 'boolean' ? version : undefined);
},
// isISIN(str) - check if the string is an ISIN (stock/security identifier).
isISIN: validator.isISIN,
// isIn(str, values) - check if the string is in a array of allowed values.
fork icon0
star icon1
watch icon3

+ 17 other calls in file

122
123
124
125
126
127
128
129
130
131
'isbn10': {
  method: (val) => V.isISBN(val, 10),
  message: 'ISBN (version 10) string'
},
'isbn13': {
  method: (val) => V.isISBN(val, 13),
  message: 'ISBN (version 13) string'
},
// check if the string is an ISSN. (https://en.wikipedia.org/wiki/International_Standard_Serial_Number)
'issn': {
fork icon0
star icon0
watch icon0