isbn validator
Validate an ISBN (International Standard Book Number)
The validator support both ISBN 10 and ISBN 13.
Options
Using with form field
Name | HTML attribute | Type | Description |
---|
message | data-fv-isbn___message | String | The error message |
Using the ES6 module
import { isbn } from '/vendors/@form-validation/cjs/validator-isbn';
const result = isbn().validate({
value: ...,
options: {
message: ...,
},
});
Using the npm package
- Install the validator package:
$ npm install @form-validation/validator-isbn
import { isbn } from '@form-validation/validator-isbn';
const result = isbn().validate({
value: ...,
options: {
message: ...,
},
});
Basic example
NPM package example
The following snippet shows how to use the isbn validator with the npm package:
import { isbn } from '@form-validation/validator-isbn';
const res1 = isbn().validate({
value: '9971502100',
options: {
message: 'The value is not valid ISBN',
},
});
const res2 = isbn().validate({
value: '99921-58-10-6',
options: {
message: 'The value is not valid ISBN',
},
});
See also
Changelog