简体   繁体   中英

Joi validation when multiple conditions are met

I need to validate one field of object when two fields of same object is true. I have an object like

person={
 is_active: // either true or false
 is_valid: // either true or false
 username :'' // validation required field
}

so i have to do validation like

if (is_active==true && is_valid==true)

then only i have to validate username like

Joi.string().required()

I have tried the nested when condition but it throws Assertion Error

如此对用户名所述,使用is子句

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