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

Name HTML attribute Type Description
message data-fv-grid___message String The error message

Using with JavaScript module


// You might need to change the importing path
import grid from 'formvalidation/validators/grid';

const result = grid().validate({
    value: ...,
    options: {
        message: ...,
    },
});
/*
result is an object of
{
    valid: true or false,
    message: The error message     
}
*/

Basic Example

You can click on sample to see if it's a valid or invalid GRId.

Sample Is valid?
A12425GABC1234002M
A1-2425G-ABC1234002-M
A1 2425G ABC1234002 M
Grid:A1-2425G-ABC1234002-M
A1-2425G-ABC1234002-Q

Module Example

The following snippet shows how to use the grid validator with JavaScript module:


// You might need to change the importing path
import grid from 'formvalidation/validators/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

Related validators

The following validators are similar to this one and might be useful to you.

Name Description
ismn Validate an ISMN (International Standard Music Number)