Answers for "JOI complex when"

0

JOI complex when

// a === 'avalue' || b === 'bvalue'

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() }))
};

// a === 'avalue' && b === 'bvalue'

var schema = {
  a: Joi.string(),
  b: Joi.string(),
  c: Joi.string().when(
    'a', {
      is: 'avalue',
      then: Joi.when(
        'b', {
          is: 'bvalue',
          then: Joi.string().required()
        }
      )
    }
  )
};
Posted by: Guest on June-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language