meid validator

Validate a MEID (mobile equipment identifier)

Options

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

Basic example

meid validator

NPM package example

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

See also

Changelog

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