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

not validate octane relations #209

Open
wallacyalva opened this issue Aug 23, 2022 · 1 comment
Open

not validate octane relations #209

wallacyalva opened this issue Aug 23, 2022 · 1 comment

Comments

@wallacyalva
Copy link

validate my relation is presence but is not validate .
i try validate a computed relation id is it working, probably it is check relation but is not checked a content of relation

  @belongsTo('city') city;
  @belongsTo('state') state;
  
  @computed('state') get state2() {
    return get(this,'state.id');
  }

  @computed('city') get city2() {
    return get(this,'city.id');
  }

validations = {
      city2:{
        presence: {
          message: "A cidade é necessária."
        },
      },
      state2:{
        presence: {
          message: "O estado é necessário."
        },
      },
      city:{
        presence: {
          message: "A cidade é necessária."
        },
      },
      state:{
        presence: {
           message: "O estado é necessário."
        },
      }
}
@corrspt
Copy link

corrspt commented Oct 17, 2023

I think I'm being bit by this as well. The relationship has a value but when ember-model-validator tries to get ${property}.content that comes out empty. Were you able to find a workaround @wallacyalva ? Thanks!
I'm on ember/cli/data 3.28 with ember-model-validator 4.7

EDIT: After a few more rounds of research it seems I have a specific situation(?) the relations that aren't being validated have this particular validation definition:

presence: {
       message(_key: string, _value: string, model: any): string {
              return model.translate('generic.error.input-value');
       }
}

If I switch to a custom validation that checks something... it seems to work now 🤷
But this used to work fine in 3.X :)

EDIT2: After testing out my app I've found a instance of having only presence:true for a model and ember-model-validator telling me that the content does not exist (but it's there)

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

2 participants