I'm using custom messages in a validation with Laravel, most of them work for me but specifically the ones that are requiredIf don't work for me.
I've seen them used like this:
protected $mensajes = [
'salas.required_if' => 'mensaje personalizado',
'dormitorios.required_if' => 'mensaje personalizado'
]
but that doesn't work for me. I clarify that if it takes the data as mandatory when the condition is met, but it does not send the message that I defined, it sends one that I understand is predefined:
"The rooms field is mandatory"
"The bedrooms field is mandatory"
My condition is something like this:
$arreglo['salas'][] = Rule::requiredIf(function() use($request)
{
return $request->filled('dormitorios') ? false : true;
})
$arreglo['dormitorios'][] = Rule::requiredIf(function() use($request)
{
return $request->filled('salas') ? false : true;
})
To give a little more context as to what I want to do, I am receiving two arrangements in a request (living rooms, bedrooms), but I want at least one or both of them to always come, but if both are absent it would be wrong, and thus the validation of the requiredIf .