Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow enum type for validation groups #45494

Closed as not planned
Closed as not planned
@Guuzen

Description

@Guuzen

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.

TypeError : Illegal offset type
vendor/symfony/validator/Mapping/GenericMetadata.php:167

Example

enum MyEnum: string
{
    case CASE_ONE = 'CASE_ONE';
    case CASE_TWO = 'CASE_TWO';
}

#[Assert\Callback(groups: [MyEnum::CASE_ONE])]
class Foo
{    
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions