Skip to content

How to validate entity's proprty with enum type #5984

Description

@alebedev80

There is an entity with property $language:

private Language $language = Language::ES;

On post request data with language from enum list (e.g. es) all is ok. But if value out of list response error (e.g. 00):

{
    "title": "An error occurred",
    "detail": "The data must belong to a backed enumeration of type App\\Core\\Language",
    "status": 400,
    "type": "/errors/400"
}

Choice and custom validator useless because they execute AFTER deserialization where that error appears. So i need proper 422 error response. What and how to fix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions