3
I have two CPF and CNPJ fields, the user must type only one, but never leave the two fields empty. This way it makes mandatory the two fields:
[
'Cpf' => array('required'),
'Cnpj' => array('required'),
]
Is there any way in Laravel to validate only one required field when one is completed?
What version of Laravel ?
– Diego Souza
Try it this way:
'cpf' => 'required|required_without_all:cnpj', 'cnpj' => 'required|required_without_all:cpf',
– Diego Souza
@Zooboomafoo VERSION = '5.1.45 (LTS)';
– scooby
@Zooboomafoo I think it doesn’t work for this version: Method [validateRequired|requiredWithoutAll] does not exist.
– scooby