i have form request like this
{
"data": [
{
"transaction": "LNS",
"product": "XXX",
"lot": "1",
"liquidPrice": "0",
"liquidId": 0,
"limitPrice": "1780.00",
"stopPrice": "0"
},
{
"transaction": "LNS",
"product": "XXX",
"lot": "1",
"liquidPrice": "0",
"liquidId": 0,
"limitPrice": "1780.00",
"stopPrice": "0"
}
]
}
i want to check if the array data bigger than one object, the value of key object product must same as another array of object
You can follow these steps for check of key object
Check this example :
let Joi = require('joi')
let service = Joi.object().keys({
serviceName: Joi.string().required(),
})
let services = Joi.array().items(service)
let test = Joi.validate(
[{ serviceName: 'service1' }, { serviceName: 'service2' }],
services,
)
you using Joi validation libary:
Joi.array().items({
"transaction": Joi.string().required(),
...
}).min(1)