Created
June 17, 2017 15:42
-
-
Save blogui91/fdaefe259d24d126aa2cb7341fbc0256 to your computer and use it in GitHub Desktop.
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 ClientValidator from 'validators/Client.validator' | |
let clientData = { | |
fullname : 'Cesar Santana', | |
email : 'example@@email.com', //Wrong | |
age : 'asdf' //Wrong | |
} | |
let validation = ClientValidator.make(clientData) | |
/* | |
* The make function returns an object with these properties: | |
* has() : Boolean //Verify if a specified item has error. | |
* first() : Array //Get the first field with error. | |
* get() : Array //Get a specified field with error. | |
* passes() : Boolean //Check if the validation does not have errors. | |
* fails() : Boolean // Check if validation has errors. | |
*/ | |
if(validation.passes(){ | |
//saveClient(); | |
}else if(validation.fails()){ | |
console.error(validation.messages) //Show the | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment