0
I created a request class and inject it into the store method of the controler. My Rules method within the class has the following key:
public function rules()
{
return [
//...
'campo_id' => 'sometimes|nullable|exists:tabela,pk',
//...
];
}
when the value is null and enters this validation, it falls into the exists validation and returns the corresponding message. My intention is to leave null itself. Any suggestions?
I see that nullable allows the field to be null, but exists forces you to have something. It didn’t work for me here. Vlw by force!
– Emmanuel de Carvalho Garcia
ta using in an api ?
– junio hyago
No friend, I’m using it the way I put it in the post. No api
– Emmanuel de Carvalho Garcia
I am using this way with api and this run.
– junio hyago
I found the problem, it was in a Istener. It really works!
– Emmanuel de Carvalho Garcia
So congratulations and that
– junio hyago
Put as answered there to help =D
– junio hyago
Vote and acceptance should not be given for passionate reasons. Vote as useful not useful. And it is accepted, preferably among the useful, the best answer.
– Augusto Vasques