Skip to content

Instantly share code, notes, and snippets.

@brunoluiz
Last active August 24, 2017 12:44
Show Gist options
  • Save brunoluiz/fafa0fbcc032c4fd58612e4798f11849 to your computer and use it in GitHub Desktop.
Save brunoluiz/fafa0fbcc032c4fd58612e4798f11849 to your computer and use it in GitHub Desktop.
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