yup examples

node v0.12.18
version: master
endpointsharetweet
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