I am trying to add a validation for array in a POST request
Joi.array().items(Joi.string()).single().optional()
I need to allow null values in the payload. Can you please tell me how this can be done ?
I am trying to add a validation for array in a POST request
Joi.array().items(Joi.string()).single().optional()
I need to allow null values in the payload. Can you please tell me how this can be done ?
I know what i'm posting is not what you are looking for, but as i was ran into similar type of problem.
so my problem was: I do not want to allow empty array in my object
my solution:
// if you have array of numbers
key: joi.array().items(joi.number().required()).strict().required()
// if you have array of strings
key: joi.array().items(joi.string().required()).strict().required()
If you want to allow the array to be null use:
If you want to allow null or whitespace strings inside the array use:
Example: