Last active
January 28, 2021 18:27
-
-
Save mkozhukharenko/0eb44b37a2968752d5d55638e1b90551 to your computer and use it in GitHub Desktop.
Example of validatorjs usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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