issn validator

Validate an ISSN (International Standard Serial Number)

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
NameHTML attributeTypeDescription
messagedata-fv-issn___messageStringThe error message
Using the ES6 module
// You might need to change the importing path
import { issn } from '/vendors/@form-validation/cjs/validator-issn';
const result = issn().validate({
value: ...,
options: {
message: ...,
},
});
/*
result is an object of
{
valid: true or false,
message: The error message
}
*/
Using the npm package
  • Install the validator package:
$ npm install @form-validation/validator-issn
  • Use the issn validator:
import { issn } from '@form-validation/validator-issn';
const result = issn().validate({
value: ...,
options: {
message: ...,
},
});

Basic example

issn validator

NPM package example

The following snippet shows how to use the issn validator with the npm package:
import { issn } from '@form-validation/validator-issn';
const res1 = issn().validate({
value: '0024-9319',
options: {
message: 'The value is not valid ISSN',
},
});
// res1.valid === true
const res2 = issn().validate({
value: '0032-147X',
options: {
message: 'The value is not valid ISSN',
},
});
// res2.valid === false

See also

Changelog

v2.0.0
  • Add the npm package