mercredi 11 juillet 2018

Validation only required when value is not avaialbe

I have the following code:

{!! Form::select('the_selection', ['' => 'Nothing', 'Foo' => 'Bar']) !!}

And the following:

<input class="input" name="the_other_field" type="text"/>

The the_other_field field should be required only when the_selection is not '' .

So I tried tis validation:

$this->validate($request, [
    // 'recurring'        => 'required|nullable',
    'the_other_field'      => 'required_without:the_selection,|date_format:Y-m-d|after:today',
]);

But that doesnt work..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire