Nettet21. mai 2024 · 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 })) Solution 2. If you want to validate an array of strings in Joi: Nettet20. mai 2024 · You cannot directly pass the tags input to Joi validation, because it is a string representation of an array. You can first parse it - let parsedTags = []; if (tags) { …
JOI alternatives try - need one to be required - Stack Overflow
Nettet21. okt. 2024 · const Joi = require ("@hapi/joi"); const roles = ["admin", "staff"]; const schema = Joi.object ( { first_name: Joi.string ().min (1), last_name: Joi.string () .min … Nettet14. apr. 2024 · 我有一组 Joi 字符串: const item = Joi.string().max(50) const items = Joi.array().items(item).max(20) 每个单独的项目最多可以有 50 个字符,并且最多有 20 个项目。 到目前为止一切顺利,但是..... 我还必须验证数组中所有字符串的总长度不超过 200 个字符。 纯粹在 Joi 中有可能吗? cine proyector 4k
Joi.array() does not allow arguments when trying to validate an array …
Validate array of strings with joi, must be strings. I need to validate an array to check if it's elements are strings using joi. It always sends the error of "Inavlid tag". // returned array from req.body let tags = ["Vue", "React", "Angular"] // joi shema const schema = { tags: Joi.array ().items (Joi.string ()), }; const { error ... Nettet21. sep. 2016 · I am using Node Joi for validation. I am new in node I want to validate env to accept only 2 words "Yes" or "No" What changes I have to make in the following … NettetThis works: -> color: Joi.array ().items (Joi.string ()).single (), However when I add valid, I get the error "child "color" fails because ["color" must be one of [Red, Blue]]": -> color: … diablo towing