-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Allow enum type for validation groups #45494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Closing as explained in the linked PR: this is an engine-level consideration that should be fixed either by https://wiki.php.net/rfc/fetch_property_in_const_expressions or https://wiki.php.net/rfc/auto-implement_stringable_for_string_backed_enums |
@nicolas-grekas I think this should be reconsidered. Is there a reason for the Enum to be Backed? What about making Pure Enums possible as validation group?: enum Group
{
case Foo;
case Bar;
}
#[Assert\Callback(groups: [Group::Foo])]
class Whatever
{
} |
A group is a string and we cannot guess the string representation of a non-backed enum. |
Yes, but the question is if it would be possible to also allow the enum type (besides |
Why? What's the use case? |
Getting rid of strings - this looks like the "natural" use case for all enums to me :-) |
What happened to constants for that matter? |
Description
Validation groups is often predefined set of strings. Seems like it make sense to use enum for this. Probably backed string enums.
Right now there is an error if you try to use enums for groups.
Example
The text was updated successfully, but these errors were encountered: