vin validator
Validate an US VIN (Vehicle Identification Number)
Options
Using with form field
Name | HTML attribute | Type | Description |
---|
message | data-fv-vin___message | String | The error message |
Using the ES6 module
import { vin } from '/vendors/@form-validation/cjs/validator-vin';
const result = vin().validate({
value: ...,
options: {
message: ...,
},
});
Using the npm package
- Install the validator package:
$ npm install @form-validation/validator-vin
import { vin } from '@form-validation/validator-vin';
const result = vin().validate({
value: ...,
options: {
message: ...,
},
});
Basic example
NPM package example
The following snippet shows how to use the vin validator with the npm package:
import { vin } from '@form-validation/validator-vin';
const res1 = vin().validate({
value: '192.168.1.1',
options: {
message: 'The value is not valid IP address',
},
});
const res2 = vin().validate({
value: 'JTMKF4DV5B5309254',
options: {
message: 'The value is not valid VIN',
},
});
Changelog