Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Error handling? #106

Open
mukezhz opened this issue Apr 23, 2024 · 5 comments
Open

Validation Error handling? #106

mukezhz opened this issue Apr 23, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@mukezhz
Copy link
Member

mukezhz commented Apr 23, 2024

Instead of sending just validation error, how about sending error in the following format?

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Struct Full Field",
      "message": "This field is required"
    }
  ]
}

PR: #107

@mukezhz mukezhz added enhancement New feature or request question Further information is requested labels Apr 23, 2024
@paudelgaurav
Copy link
Member

paudelgaurav commented Apr 23, 2024

Instead of sending just validation error, how about sending error in the following format?

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Struct Full Field",
      "message": "This field is required"
    }
  ]
}

PR: #107

@mukezhz Could you attach the response for nested structs ?

@Denes-cilwal
Copy link
Contributor

Denes-cilwal commented Apr 23, 2024

Instead of sending just validation error, how about sending error in the following format?

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Struct Full Field",
      "message": "This field is required"
    }
  ]
}

PR: #107

@mukezhz Could you attach the response for nested structs ?

we can add binding:"dive" for nested struct

@Denes-cilwal
Copy link
Contributor

Instead of sending just validation error, how about sending error in the following format?

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Struct Full Field",
      "message": "This field is required"
    }
  ]
}

PR: #107

@mukezhz Could you attach the response for nested structs ?

we can add binding:"dive" for nested struct

@mukezhz

@mukezhz
Copy link
Member Author

mukezhz commented Apr 26, 2024

Instead of sending just validation error, how about sending error in the following format?

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Struct Full Field",
      "message": "This field is required"
    }
  ]
}

PR: #107

@mukezhz Could you attach the response for nested structs ?

@paudelgaurav here's the response of the error

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Parent Struct. Field",
      "message": "This field is required"
    }
  ]
}

example:

{
  "errors": [
    {
      "field": "Products",
      "full_field": "OrderInputV2.Products",
      "message": "This field is required"
    },
    ...
  ]
}

@paudelgaurav
Copy link
Member

Instead of sending just validation error, how about sending error in the following format?

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Struct Full Field",
      "message": "This field is required"
    }
  ]
}

PR: #107

@mukezhz Could you attach the response for nested structs ?

@paudelgaurav here's the response of the error

{
  "errors": [
    {
      "field": "field name",
      "full_field": "Parent Struct. Field",
      "message": "This field is required"
    }
  ]
}

example:

{
  "errors": [
    {
      "field": "Products",
      "full_field": "OrderInputV2.Products",
      "message": "This field is required"
    },
    ...
  ]
}

@mukezhz Thank you.
Looks good to me, I only have one concern regarding the field name. Will it show the name from json:"" annotation or directly from srtuct ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants