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

Has-many relationship propagates 'messages' property but not 'errors' property #685

Open
BlueRaja opened this issue Sep 23, 2020 · 0 comments

Comments

@BlueRaja
Copy link

BlueRaja commented Sep 23, 2020

Environment

  • Ember Version: 3.16
  • Ember CLI Version: 3.16?
  • Ember CP Validations Version: 4.0.0-beta.10

Steps to Reproduce

Here is our setup, with doubly-nested classes. It might reproduce with only a single layer of nesting, though:

outerClass:

buildValidations({
  middleClass: validator('has-many'),
});

middleClass:

buildValidations({
  innerClass: validator('has-many'),
});

innerClass:

buildValidations({
    value: validator('presence', { presence: true }),
});

Here is what the data looks like:

///////////////////////////////////
// outerClass validations
///////////////////////////////////
this.get('outerClass.validations.isValid')
> false

this.get('outerClass.validations.messages')
> ["This field can't be blank"]

this.get('outerClass.validations.errors')
> []

///////////////////////////////////
// Access middleClass through validations.attrs
///////////////////////////////////
this.get('outerClass.validations.attrs.middleClass.isValid')
> false

this.get('outerClass.validations.attrs.middleClass.messages')
> ["This field can't be blank"]

this.get('outerClass.validations.attrs.middleClass.message')
> "This field can't be blank"

this.get('outerClass.validations.attrs.middleClass.errors')
> []

this.get('outerClass.validations.attrs.middleClass.error')
> undefined

///////////////////////////////////
// Access middleClass directly:
///////////////////////////////////
this.get('outerClass.middleClass.0.validations.messages')
> ["This field can't be blank"]

this.get('outerClass.middleClass.0.validations.errors')
> []

///////////////////////////////////
// Access innerClass through middleClass.validations.attrs
///////////////////////////////////
this.get('outerClass.middleClass.0.validations.attrs.innerClass.messages')
> ["This field can't be blank"]

this.get('outerClass.middleClass.0.validations.attrs.innerClass.errors')
> []

///////////////////////////////////
// Access innerClass directly
///////////////////////////////////
this.get('outerClass.middleClass.0.innerClass.0.validations.messages')
> ["This field can't be blank"]

this.get('outerClass.middleClass.0.innerClass.0.validations.errors')
> [Class]

As you can see, the innerClass has an error on it, but the hasMany is not propagating it.

Based on the documentation, it shouldn't be possible for errors to be empty but messages non-empty. In fact, based on (what I assume is) the code, it looks like error shouldn't ever be undefined

@BlueRaja BlueRaja changed the title Invalid object has 'message' property but no 'error' property Has-many relationship propagates 'message' property but not 'error' property Sep 23, 2020
@BlueRaja BlueRaja changed the title Has-many relationship propagates 'message' property but not 'error' property Has-many relationship propagates 'messages' property but not 'errors' property Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant