I want to make a field mandatory if another field contains the "{" character.
I've tried several combinations but it looks like Laravel doesn't apply the rule at all.
public function rules()
{
$rules = [
'title' => 'required',
'url' => 'required',
'model_name' => 'required_if:url,url:regex:/{/',
// The following doesn't work either:
// 'model_name' => 'required_if:url,url:not_regex:/{/',
// 'model_name' => 'required_if:url,regex:/{/',
// 'model_name' => 'required_if:url,not_regex:/{/',
];
return $rules;
}
Any idea ?
required_if:url,regex:/{/this should work