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

Add support for nested keys in validation rules #132

Merged
merged 4 commits into from
Mar 9, 2016
Merged

Conversation

offirgolan
Copy link
Collaborator

Resolves #131

import Ember from 'ember';
import { validator, buildValidations } from 'ember-cp-validations';

const Validations = buildValidations({
  'user.firstName': validator('presence', true),
  'user.lasName': validator('presence', true),
  'account.number': validator('presence', true),
});

export default Ember.Component.extend(Validations, {
  user:  { firstName: 'bob', lastName: 'billy' } ,
  account: { number: 123, balance: 456 }

  isFormValid: Ember.computed.alias('validations.isValid'),
});

@offirgolan
Copy link
Collaborator Author

@stefanpenner @rwjblue open for review

@donovan-graham
Copy link

This looks great. Looking forward to it being merged.

@@ -102,11 +104,15 @@ function setOwner(obj, model) {
export default function buildValidations(validations = {}) {
processDefaultOptions(validations);

const Validations = createValidationsObject(validations);
var Validations;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let

offirgolan added a commit that referenced this pull request Mar 9, 2016
Add support for nested keys in validation rules
@offirgolan offirgolan merged commit 5caf2ed into master Mar 9, 2016
@offirgolan offirgolan deleted the nested-keys branch March 9, 2016 19:44
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.

3 participants