Skip to content
Advertisement

how to exclude a rule in laravel validation

I am building a user’s resignation inside the dashboard with Form Request Validation. it works well in store resource, but I need to exclude the password role in updating resource, so if the user leaves it empty I will store the old password

my validation file

JavaScript

Advertisement

Answer

In this case just use 'sometimes' for updating password and not 'required'.

JavaScript

Validating when present see docs here: sometimes rule laravel

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement