简体   繁体   中英

Not able to get message of empty or required field using Joi npm package

Joi package Version: ^17.6.0

I'm trying to get the error of the array of object keys. Reference Image of Joi Validation:

Joi 验证的参考图像

Json Data:

json数据

In this picture, I'm validating most of the fields using Joi, However when I try to validate an array of objects then I get the locations array message. Though, The empty or required is in items of the array.

How can I solve this?

You need to use array.min(1) validation to specify that at least 1 item is required. Also there doesn't seem to be any array.empty error so you need to use array.min .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM