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

Expose disabled validator option #106

Merged
merged 3 commits into from
Jan 28, 2016
Merged

Expose disabled validator option #106

merged 3 commits into from
Jan 28, 2016

Conversation

offirgolan
Copy link
Collaborator

Resolves #104

  • Exposes disabled option for validators
  • Add functionality to define dependentKeys in default options (should have already been there)

This will allow to do the following

// Via default options
const Validations = buildValidations({
  username: {
    debounce: 500,
    disabled() { return !this.get('model._enableValidations'); },
    dependentKeys: ['_enableValidations'],
    validators: [
      validator('presence', true),
      validator('length', {
        max: 15
      })
    ]
  }
});

// Via single validator
const Validations = buildValidations({
  username: validator('presence', {
    presence: true,
    disabled() { return !this.get('model._enableValidations'); },
    dependentKeys: ['_enableValidations']
  })
});

export default DS.Model.extend(Validations, {
  'username': attr('string'),
  _enableValidations: true
});

@stefanpenner @rwjblue open for comments.

@offirgolan
Copy link
Collaborator Author

ready for review 😺

offirgolan added a commit that referenced this pull request Jan 28, 2016
Expose disabled validator option
@offirgolan offirgolan merged commit b8ae482 into master Jan 28, 2016
@offirgolan offirgolan deleted the enabled-option branch January 28, 2016 18:53
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

Successfully merging this pull request may close these issues.

1 participant