0

Errors on attributes located within related models is now my problem. I can see the errors on these related models by doing model.errors.content or model.errors.messages but if I want to check a particular attribute on a related model in order to highlight field errors I get null or undefined values.

See below screen shot for more info

Invaild Error object: enter image description here

Model After error: In this object i am getting the attribute and message but i use model.get("errors.phone"

enter image description here

Arun
  • 91
  • 3
  • can you show what response your backend is giving, when validations fail? I suspect your error json is in wrong format – qnsi Jan 14 '16 at 14:34
  • Did you include your validations mixin? – Remi Smirra Jan 14 '16 at 15:06
  • please specify your ember and ember-data versions. – mihai Jan 14 '16 at 20:06
  • {"errors":{"phone":["is invalid"]}} Yes i have included validation mixin Ember : 1.13.13 Ember-data : 2.2.1 – Arun Jan 15 '16 at 12:42
  • Did you ever find the reason for this? I am finding myself in somewhat the same boat. My errors are not being populated as I expect. I am using the correct JSON API format expected. – Gurnzbot Oct 05 '16 at 18:08
  • i have used model.errors.content it will return an array i used that array to display my error message – Arun Oct 07 '16 at 07:12

1 Answers1

0

My best guess is, you need to update your error serializer to send data in a format expected by Ember Data JSON Adapter.

It's best explained in detail in this stackoverflow answer, but as a gist you should format your data in a following way:

{
  "errors": 
  [
    {
      "detail": "is invalid",
      "source": {
        "pointer": "data/attributes/phone"
      }
    }
  ]
}  

The pointer must correspond to your model attribute, so phone in this example.

Community
  • 1
  • 1
qnsi
  • 370
  • 4
  • 14