Nettet我正在收到一系列对象,每个对象都包含一个服务名称.该结构看起来像[{serviceName:service1},{serviceName:service2},..]当我在后端获得数组时,我想验证数组中的每个对象都有ServiceName属性. 我编写了以下代码,但是即使我通过有效数组,我也会收到验证错误.var Joi NettetJoi. array ().items(Joi.object().keys({ name: Joi.string().required(), value: Joi.required() })).unique((a, b) => a.name === b.name) origin: jarontai / express-vue-admin name: …
Joi.array() does not allow arguments when trying to validate an array …
Nettet16. feb. 2024 · 1. I am using Joi for my project server side validation. I have an array which is populate from database for eg: let s = ['a','b','c']; Now I need to check if for a … Nettet16. apr. 2024 · In this specific case, the items are an object but this method can support any combination of comma-separated Joi schemas. For example, if our array would only contain a required string and an optional number our schema could look like this: Joi.array().items(Joi.string().required(), Joi.number()) Back to our original credit card … scooter audi
joi.dev - 17.9.1 API Reference - joiSite
Nettet24. feb. 2024 · Joi.array() just tells Hapi that the status query parameter is an array..single() tells joi to wrap your query parameter in an array when validating the value if it has only one value..items(Joi.string()) tells joi that the array is supposed to contain only string values..rename('status[]', 'status', { ignoreUndefined: true }) well that’s the … Nettet6. okt. 2024 · In this specific case, the items are an object but this method can support any combination of comma-separated Joi schemas. For example, if our array would only contain a required string and an optional number our schema could look like this: Joi.array().items(Joi.string().required(), Joi.number()) Back to our original credit card … Nettet'set' - supported by the Joi.array() type, converts the result to a Set object containing the array values. 'string' - supported by Joi.binary(), Joi.boolean(), Joi.date(), and Joi.number(), converts the result to a … scooter auf sylt 2023