Required_if validator with array of values adonis

as in laravel as here required_if can be passed with multiples values against any field. is there a way to use this in adonis.

1 Like

Hello :wave:. If you want to test with multiples values you have to use requiredWhen :

const rules = {
    role: "required",
    role_details: "required_when:role,1,2" // Required if role is 1 or 2
};
3 Likes

only validating first value. it is letting go without validating when role is 2

1 Like