ein validator

Validate an EIN (Employer Identification Number)

Options

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

Basic example

ein validator

NPM package example

The following snippet shows how to use the ein validator with the npm package:
import { ein } from '@form-validation/validator-ein';
const res1 = ein().validate({
value: '91-1144442',
options: {
message: 'The value is not valid EIN',
},
});
// res1.valid === true
const res2 = ein().validate({
value: '123-45-6789',
options: {
message: 'The value is not valid EIN',
},
});
// res2.valid === false

Changelog

v2.0.0
  • Add the npm package