cusip validator

Validate a CUSIP number

Options

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

Basic example

cusip validator

NPM package example

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

See also

Changelog

v2.0.0
  • Add the npm package
v1.7.0
  • Fixed an issue that the cusip validator doesn't work properly