Skip to content

Using Enum objects in expression language #48593

Closed
@igst

Description

@igst

Description

Hi,

would be nice if it would be possible to use native enum objects in expression language context similar to constants.
See expression option of "When" Constraint in the following example.

cc @mvhirsch

Example

#[When(
    expression: 'this.type.equalsOneOf([
        enum(App\Type::CAR),
        enum(App\Type::BICYCLE),
    ])',
    constraints: [
        new NotBlank(),
        new GreaterThan(value: 0),
    ]
)]
public ?int $wheelAmount;

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