swisnl / json-api-server

Set up a JSON API in Laravel in just a few minutes.
MIT License
105 stars 18 forks source link

Json api validator bad response #25

Open bondas83 opened 5 years ago

bondas83 commented 5 years ago

When i validating fields with validateObject function, i get error response like:

{
"message": "The given data was invalid.",
"errors": {
  "status": [
    "The status field is required."
  ],
  "expiry_date": [
    "The expiry date field is required."
  ]
}
}

Which is not valid jsonapi error response.

valid should be:

{
  "errors": [
    {
      "source": { "parameter": "status" },
      "title": "The given data was invalid.",
      "detail":  "The status field is required."
    },
    {
      "source": { "parameter": "expiry_date" },
      "title": "The given data was invalid.",
      "detail":  "The expiry date field is required."
    }
  ]
}
bbrala commented 5 years ago

Valid point, this format is indeed wrong.