Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
yup examples
node v0.12.18
version:
master
endpoint
share
tweet
Define your schema by combining yup schema objects and use them to parse objects
const yup = require('yup') const contactSchema = yup.object({ name: yup.string() .required(), age: yup.number() .required() .positive() .integer() }) const errors = await contactSchema.validate({ name: 'Kenneth', age: -35.5 }).catch(function(err) { return err }); console.log("errors", errors);
Loading…
no comments
sign in
to comment