Last active
August 24, 2017 12:44
-
-
Save brunoluiz/fafa0fbcc032c4fd58612e4798f11849 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
const schema = require('./rating-schema') | |
const result = schema.validate({ | |
username: 'brunoluiz', | |
rating: 5, | |
email: '[email protected]' | |
}) | |
console.log(result) // result.error will be null | |
// result.error will show an error due to missing e-mail | |
const resultWithError = schema.validate({ | |
username: 'brunoluiz', | |
rating: 5, | |
}) | |
console.log(resultWithError)// result.error will have an error message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment