grid validator

Validate a GRId (Global Release Identifier)

Options

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

Basic example

grid validator

NPM package example

The following snippet shows how to use the grid validator with the npm package:
import { grid } from '@form-validation/validator-grid';
const res1 = grid().validate({
value: 'A12425GABC1234002M',
options: {
message: 'The value is not valid GRId',
},
});
// res1.valid === true
const res2 = grid().validate({
value: 'A1-2425G-ABC1234002-Q',
options: {
message: 'The value is not valid GRId',
},
});
// res2.valid === false

See also

Changelog

v2.0.0
  • Add the npm package