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

Allow to use if condition with relations #356

Open
ixxvivxxi opened this issue Feb 19, 2025 · 1 comment
Open

Allow to use if condition with relations #356

ixxvivxxi opened this issue Feb 19, 2025 · 1 comment

Comments

@ixxvivxxi
Copy link

The documentation says that you can use if together with relations validations. Can anyone help me figure out how to use this?

ixxvivxxi added a commit to ixxvivxxi/ember-model-validator that referenced this issue Feb 19, 2025
ixxvivxxi added a commit to ixxvivxxi/ember-model-validator that referenced this issue Feb 19, 2025
@ixxvivxxi
Copy link
Author

example:

validations = {
   types: {
      relations: {
        if(key, value, model) {
          return model.get('status') !== 'OK';
        },
        value: ['hasMany'],
      },
    },
    category {
      relations: {
        if(key, value, model) {
          return model.get('status') !== 'OK';
        },
        value: ['belongsTo'],
      },
    },
}

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