Skip to content

Instantly share code, notes, and snippets.

@mkozhukharenko
Last active January 28, 2021 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkozhukharenko/0eb44b37a2968752d5d55638e1b90551 to your computer and use it in GitHub Desktop.
Save mkozhukharenko/0eb44b37a2968752d5d55638e1b90551 to your computer and use it in GitHub Desktop.
Example of validatorjs usage
import Validator from 'validatorjs'
var data = {
name: 'John',
email: 'not-valid-email'
};
var rules = {
name: 'required',
email: 'required|email'
};
var validation = new Validator(data, rules);
validation.passes(); // false
validation.errors.first('email'); // 'The email format is invalid.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment