M
M
Mikhail2021-01-27 22:37:08
Laravel
Mikhail, 2021-01-27 22:37:08

Why is required_if validation not working?

'form' => 'bail|required|array',
'form.type' => 'bail|required|string|in:one,two',
'form.method' => 'bail|required_if:form.type,one|string|min:1|max:8',

The request comes:
form [
   'type' => 'two',
   'method'' => '',
]

But the validation swears that method must be a string and at least 1 character. Why??? In the same place before this is required_if
Or is required_if somehow not working with nested parameters? Since the type key is in the form key Is
required_if:form.type not working?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2021-01-28
@Alex_Wells

Because required has no effect on other rules. Need nullable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question