Required field validation in patch method

In the API I am developing, I need to call a patch method to update some user information.

I wonder if it’s possible to check if the field is only required if it’s in the request.

I know that in laravel there is a validation called sometimes, does Adonis have something similar?

I wonder if it’s possible to check if the field is only required if it’s in the request.

You can use a validator to set that field as required or not. And you can check if the info is in the request as you check for the presence of any JavaScript variable

Hello begueradj, could you please reply a brief draft of how the code would look like in order to implement this approach?

I want to do exactly the same as ericksena mentions in this post. I’ve seen examples in which people use ‘requiredIf:fieldname’ but I’m not pretty sure if this works that way.

Thanks for your time to respond me.