Skip to content

Localized Validation with Member Names. #313

Description

@willemtoerien

I want to make use of the mutations but am currently running into a situation with validation and errors.
Suppose I have this object:

public class MyArgClass
{
  [Required]
  public string Name { get; set; }
}

And the following query:

mutation MutationName {
  myArgClass(
    name: ""
  )
}

When I run it, I get the following response:

{
  "errors": [
    {
      "message": "Field 'myArgClass' - The Name field is required."
    }
  ]
}

The problem comes in when I want to determine the member name that is having the validation problem and when I want to localize the message.

I want to format the response of the errors to look like something this for language "af" as an example.

{
  "errors": [
    {
      "Name": "Die veld is nodig."
    }
  ]
}

And for "en":

{
  "errors": [
    {
      "Name": "This field is required."
    }
  ]
}

How would I go about achieving this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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