Not recognized more than one rule
This is my code:
what I'm trying to do is create different rules depending on what the user chooses in the select. It only works for me if I use one rule, when I use more than one it returns this error: "The given value "7|min:1" does not represent a valid number."
Select::make('frequency')
->options([
'weekly' => 'Semanalmente',
'fortnightly' => 'Quincenal',
'monthly_twice' => 'Dos veces al mes',
'monthly' => 'Mensual',
'quarterly' => 'Trimestral',
'annually' => 'Anualmente',
])->required(),
TextInput::make('frequency_day_1')->numeric()->rules([function (Closure $get) {
$frequency = $get('frequency');
\Log::alert($frequency);
switch ($frequency)
{
case 'weekly':
return 'max:7|min:1';
break;
case 'fortnightly':
return 'max:7';
break;
default:
return;
break;
}
}]),Select::make('frequency')
->options([
'weekly' => 'Semanalmente',
'fortnightly' => 'Quincenal',
'monthly_twice' => 'Dos veces al mes',
'monthly' => 'Mensual',
'quarterly' => 'Trimestral',
'annually' => 'Anualmente',
])->required(),
TextInput::make('frequency_day_1')->numeric()->rules([function (Closure $get) {
$frequency = $get('frequency');
\Log::alert($frequency);
switch ($frequency)
{
case 'weekly':
return 'max:7|min:1';
break;
case 'fortnightly':
return 'max:7';
break;
default:
return;
break;
}
}]),what I'm trying to do is create different rules depending on what the user chooses in the select. It only works for me if I use one rule, when I use more than one it returns this error: "The given value "7|min:1" does not represent a valid number."