// If you are using npm npm install --save @validate.it/rules

Usage no npm install needed!

<script type="module">
  import validateItRules from 'https://cdn.skypack.dev/@validate.it/rules';




// If you are using npm
npm install --save @validate.it/rules

// If you are using yarn
yarn add @validate.it/rules

Rule structure

Validation rules are JS objects containing a message and a check functions.

  message: Function (attribute: string, options: Object),
  check: Function (options: Object, ...args: any)


The message function defines the error message. It should return a String and it receives the following parameters:

  • attribute <String>: The name of the validated field
  • options <Object>: A object containing the rules options


This functions will validate the value. It should return a Boolean (true if passes, false if fails) and receives the following parameters:

  • options <Object>: Object containing the valaidation data:

    • attribute <String>: name of the field being validated
    • value <Any>: value of the field being validated
    • data <Object>: object containing all the fields being validated
  • ...args <Any>: the rest of the arguments are the validation rules options passed in order

Available rules

Version log

  • v0.0.x:

    • Initial commits
    • Created first rules