You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code works fine: 'status' => ['required', new EnumKey(OrderStatus::class)]
and returns this "The key you have entered is invalid."
But when we use the pipe syntax like this: 'status' => 'required|enum_key:' . OrderStatus::class
it returns: "validation.enum_key"
If it has intended to fixed, here are my suggestions
The easiest one:
Copy and paste the string like this
Validator::extend('enum_key', function ($attribute, $value, $parameters, $validator) {
$enum = $parameters[0] ?? null;
return (new EnumKey($enum))->passes($attribute, $value);
}, 'The key you have entered is invalid.');
Or do some messy things like
Validator::extend('enum_key', function ($attribute, $value, $parameters, $validator) {
$enum = $parameters[0] ?? null;
return (new EnumKey($enum))->passes($attribute, $value);
}, ((new \ReflectionClass(EnumKey::class))->newInstanceWithoutConstructor())->message());
Please let me know your idea about the solution of the issue.
The text was updated successfully, but these errors were encountered:
The following code works fine:
'status' => ['required', new EnumKey(OrderStatus::class)]
and returns this
"The key you have entered is invalid."
But when we use the pipe syntax like this:
'status' => 'required|enum_key:' . OrderStatus::class
it returns:
"validation.enum_key"
If it has intended to fixed, here are my suggestions
The easiest one:
Copy and paste the string like this
Or do some messy things like
Please let me know your idea about the solution of the issue.
The text was updated successfully, but these errors were encountered: