uuid validator

Validate an UUID

Options

Using with form field
The HTML attributes are used to set the validator options via the Declarative plugin
NameHTML attributeTypeDescription
messagedata-fv-uuid___messageStringThe error message
versiondata-fv-uuid___versionStringThe UUID version. Can be 3, 4, 5 or all (the default version)
Using the ES6 module
// You might need to change the importing path
import { uuid } from '/vendors/@form-validation/cjs/validator-uuid';
const result = uuid().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-uuid
  • Use the uuid validator:
import { uuid } from '@form-validation/validator-uuid';
const result = uuid().validate({
value: ...,
options: {
message: ...,
},
});

See also

Changelog

v2.1.0
  • The validator doesn't work properly if the message property isn't defined
v2.0.0
  • Add the npm package
v1.6.0
  • Fixed an issue that the version option isn't passed to the placeholder message