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
Post a Comment