javascript - Joi validation multiple conditions -



javascript - Joi validation multiple conditions -

i have next schema:

var testschema = joi.object().keys({ a: joi.string(), b: joi.string(), c: joi.string().when('a', {'is': 'avalue', then: joi.string().required()}) });

but add together status on c field definition required when:

a == 'avalue' , b=='bvalue'

how can that?

you can concatenate 2 when rules:

var schema = { a: joi.string(), b: joi.string(), c: joi.string().when('a', { is: 'avalue', then: joi.string().required() }).concat(joi.string().when('b', { is: 'bvalue', then: joi.string().required() })) };

javascript hapijs joi

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -