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

Validations including a has-many relationship broken when lazily evaluated #686

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

Comments

@BlueRaja
Copy link

BlueRaja commented Sep 25, 2020

Environment

  • Ember Version: 3.16
  • Ember CLI Version: 3.16?
  • Ember CP Validations Version: 4

Steps to Reproduce

outerClass:

buildValidations({
  innerClasses: [
    validator('has-many'),
    validator('inline', {
      dependentKeys: ['model.innerClasses.@each.foo'],
      validate(value) { ... }
    }],
});

innerClass:

buildValidations({
    foo: validator('presence', { presence: true }),
    bar: validator('presence', { presence: true }),
});
  1. While running the app, cause both the inline and has-many validations to fail.
  2. Fix the problem with innerClass so all its validations pass, but don't fix the inline validation

Expected results

Validations fail. outerClass.validations.errors should include 1 error with type === 'inline' and attribute === 'innerClasses'

Actual results

Validations pass

Workarounds

Any one of:

  • Pass { lazy: false } to outerClass's buildValidations call.
  • Reorder the array passed to outerClass's buildValidations call so the has-many validation is last
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