I would like to accept my update validation on these criteria:
firstnameandlastnameare present and therefore required, butdeceased_atis not given- or
deceased_atis given alone
It makes sense because we could update any field, but when we record the death of someone, we will never change any field value.
$validator = Validator::make($request->all(), [
'firstname' => 'required_unless:deceased_at|max:255',
'lastname' => 'required_unless:deceased_at|max:255',
'deceased_at' => 'required_without_all:firstname,lastname|date'
]);
The required_without_all is cumbersome to use because I have to mention every field. I would prefer something like required_alone.
What is the alternative?