Node.js/Joi

[Node.js] Joi Validation with the array

brightlightkim 2022. 4. 7. 06:50

Joi.array().items() accepts another Joi schema to use against the array elements. So an array of strings is this easy:

Joi.array().items(Joi.string())

Same for an array of objects; just pass an object schema to items():

Joi.array().items(Joi.object({
    // Object schema
}))

'Node.js > Joi' 카테고리의 다른 글

[Node.js] Joi Validation Error with Json Object  (0) 2022.04.07