Mahdi mehrabi
Mahdi mehrabi

Reputation: 1744

Laravel Require if is null in database

laravel 5.8 I want a rule of laravel validation for update that be like this: only push error when the value of this field is null and this field in the database is null too

if the field is null but in the database this field has value that validation is ok

I tried this

            'logo' => 'required_without:logo',

Upvotes: 1

Views: 1276

Answers (1)

rosscooper
rosscooper

Reputation: 2045

You may have to write a custom Rule or do some checks on the field to wrap around your validation definitions.

$rules= [...];

if($model->field === null){
    $rules['logo' => 'required'];
}

Upvotes: 4

Related Questions