Right now I have this rule:
public function rules(): array
{
return [
'languages.*.description' => ['string', 'required'],
];
}
What I need is to exclude required
if the wildcard equals gb
. I could do something like this but it feels clunky:
public function rules(): array
{
return [
'languages.no.description' => ['string', 'required'],
'languages.nl.description' => ['string', 'required'],
'languages.gb.description' => ['string'],
];
}
2
Answers
I don’t think it’s clunky, if this often changes what you could do is create an array that holds your languages.
You can do this if you put the gb rule last e.g. :
Though this does not seem documented and may change in the future.