imo validator

Validate an IMO (International Maritime Organization)

Options

Use 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-imo___message String The error message

Use with JavaScript module


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

const result = imo().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 IMO.

Sample Is valid?
IMO 9074729
imo 9074729
9074729
IMO 9074728

Module Example

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


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

const res1 = imo().validate({
    value: 'IMO 9074729',
    options: {
        message: 'The value is not valid IMO',
    },
});
// res1.valid === true

const res2 = imo().validate({
    value: '9074729',
    options: {
        message: 'The value is not valid IMO',
    },
});
// res2.valid === false