Thursday 18 May 2017

Validate an array has a certain value in Joi

I have only started looking at Joi and trying to use it to validate if an array has a certain value,which is required or even if an object has a key ,which is required. For example

const arr = ['a', 'b', 'c']

Want to validate if array has value 'a' else fail.

const obj = {
 a: 'boo',
 b: 'baz',
 c: 'foo'
}

Want to validate if object has key 'a' else fail.

Thank You



via MThomas

No comments:

Post a Comment