ean validator
Validate an EAN (International Article Number)
Options
Using with form field
Name | HTML attribute | Type | Description |
---|
message | data-fv-ean___message | String | The error message |
Using the ES6 module
import { ean } from '/vendors/@form-validation/cjs/validator-ean';
const result = ean().validate({
value: ...,
options: {
message: ...,
},
});
Using the npm package
- Install the validator package:
$ npm install @form-validation/validator-ean
import { ean } from '@form-validation/validator-ean';
const result = ean().validate({
value: ...,
options: {
message: ...,
},
});
Basic example
NPM package example
The following snippet shows how to use the ean validator with the npm package:
import { ean } from '@form-validation/validator-ean';
const res1 = ean().validate({
value: '9780471117094',
options: {
message: 'The value is not valid EAN',
},
});
const res2 = ean().validate({
value: '73513536',
options: {
message: 'The value is not valid EAN',
},
});
See also
Changelog