2
I have a request class called PessoaRequest
. In this class, I validate my form to register people.
But now, some information has appeared to be entered that are not mandatory: father’s and mother’s name. When I have this information, I mark a checkbox
creating the html fields to insert this data.
In class PessoaRequest
, I have the following rules:
return [
'name' => 'required|min:3|alpha', //obrigatório com pelo menos 3 caracteres alfabéticos
'telefone_1' => 'required',//obrigatório e deve ser um email
'email' => 'required'
[....]
];
In it ,I can not put rule for fields that ask for father’s and mother’s name , because not mandatory.
I wonder if there’s a way to put probation rule inside Request
, guy :
// Se o checkbox for marcado
if($chkPais == 1 ) {
'nome_pai' => 'required',
'nome_mae' => 'required'
}
If not, how could this validation ?
From now on, thank you.
Good afternoon, thanks for the quick return. I will test here and I already speak .
– Henrique Felix
Good afternoon @Wallace , man, gave it right here. When give the 7min , mark as solved. Vlw
– Henrique Felix
All right, @Henriquefelix. I’m glad it helped. I didn’t think I could help you so fast :D
– Wallace Maxters
So , I’m a little late to deliver this registration page with this new rule. So , fell like a glove.
– Henrique Felix