Skip to content

[MapRequestPayload] Update documentation  #19586

@AurelienPillevesse

Description

@AurelienPillevesse

(PR: #19590)

Hi everyone,

I'm thinking about some use cases with the MapRequestPayload feature.

Is it possible to precise in the documentation if classes must have "built-in types" fields or not? (Like int, string, null ...)
Because I don't think that it's recommanded to use Enum directly in the class because user input (when sending payload) only contains built-in types.

For example, if using own Enum classes in the MapRequestPayload classes, if value does not match. Violations will expose the app's implementation.


enum MyEnum: string
{
    case YES: 'yes';
    case NO: 'no';
}

class MyMap
{
    public string $attribute1;
    public MyEnum $attribute2;
}

class MyController
{
    public function __invoke(#[MapRequestPayload] MyMap $input): Reponse
    {
        return ...;
    }
}

With the given example, if I receive :

{"attribute1":"hello", "attribute2": "wrong"}

I will have an error in the violations exposing my internal implementation App\...\MyEnum. That's why I'm asking to precise in the documentation to use only built-in types.

(The error comes from the denormalization because the value entered does not match any existing value in the enum)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy