Skip to content

Validation is called on optional fields that are not passed #1182

@joesaunderson

Description

@joesaunderson
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Version/Branch 1

When validating a field like so:

    ...
    config:
        description: "An input object for editing a merchant"
        fields:
            name:
                type: "String"
                validation:
                    link: 'App\Entity::$name'
            description:
                type: "String"

And using that in a mutation like

mutation {
  edit(set: {description: "Foo"}) {
    id
  }
}

I am getting an error for validation on the name field, which uses the Symfony "Assert/NotBlank" rule.

 "extensions": {
        "validation": {
          "set.name": [
            {
              "message": "Name must not be blank",
              "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3"
            }
          ]
        }
      },

Should validation be called for optional fields that are not passed in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions