RunKit + npm: joi

node v8.17.0
endpointsharetweet
var Joi = require("joi"); /*const fields = { first: ['Jon', 'Keanu', 'Mila'], last: ['Doe', 'Reeves', 'Kunis'], country: ['US', 'US', 'US'] };*/ /*const fields = { first: ['Jon', 'Keanu', ''], last: ['Doe', 'Reeves', 'Kunis'], country: ['US', 'US', 'US'] };*/ const fields = { first: 'Jon', last: 'Doe', country: 'US' }; const schema = Joi.object().keys({ first: Joi.array().items(Joi.string()).single(), last: Joi.array().items(Joi.string()).single(), country: Joi.array().items(Joi.string().valid(['US', 'UK'])).single(), }).assert('first.length', Joi.ref('last.length')) .assert('last.length', Joi.ref('country.length')); const result = Joi.validate(fields, schema); console.dir(result);
Created from: https://npm.runkit.com/joi
Loading…