ismn validator

Validate an ISMN (International Standard Music Number)

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
NameHTML attributeTypeDescription
messagedata-fv-ismn___messageStringThe error message
Using the ES6 module
// You might need to change the importing path
import { ismn } from '/vendors/@form-validation/cjs/validator-ismn';
const result = ismn().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-ismn
  • Use the ismn validator:
import { ismn } from '@form-validation/validator-ismn';
const result = ismn().validate({
value: ...,
options: {
message: ...,
},
});

Basic example

ismn validator

NPM package example

The following snippet shows how to use the ismn validator with the npm package:
import { ismn } from '@form-validation/validator-ismn';
const res1 = ismn().validate({
value: 'M230671187',
options: {
message: 'The value is not valid ISMN',
},
});
// res1.valid === true
const res2 = ismn().validate({
value: '9790060115614',
options: {
message: 'The value is not valid ISMN',
},
});
// res2.valid === false

See also

Changelog

v2.0.0
  • Add the npm package
v1.4.0
  • Fix an issue that the ismn validator passes an invalid ISMN which ends with 0