Skip to content
Advertisement

How to validate an input field if value is not null in Laravel

I am trying to create and update users with laravel 5.4

This is the validation added for create user. It works.

JavaScript

On update the password field is not required. But validate the min:6 and confirmed rule if the password field is not null. Tried with sometimes.. but not working..

JavaScript

Advertisement

Answer

try using nullable as a rule

JavaScript

see https://laravel.com/docs/5.8/validation#a-note-on-optional-fields

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