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

validation result options hash #96

Merged
merged 2 commits into from
Jan 7, 2016
Merged

validation result options hash #96

merged 2 commits into from
Jan 7, 2016

Conversation

offirgolan
Copy link
Collaborator

Should resolve #93

All built options of the validators associated with the results in this collection grouped by validator type

// Given the following validators
{
  username: [
    validator('presence', true),
    validator('length', { max: 15 }),
    validator('format', { regex: /foo/ }),
    validator('format', { regex: /bar/ }),
  ]
}
get(user, 'validations.attrs.username.options')

The above will return the following

{
  'presence': { presence: true},
  'length': { max: 15 },
  'regex': [{ regex: /foo/ }, { regex: /bar/ }]
}

This will also allow you to do the following:

{{input value=model.username
        required=model.validations.attrs.username.options.presence
        maxlength=model.validations.attrs.username.options.length.max}}

@stefanpenner
Copy link
Collaborator

👍

offirgolan added a commit that referenced this pull request Jan 7, 2016
@offirgolan offirgolan merged commit 1057203 into master Jan 7, 2016
@offirgolan offirgolan deleted the public-options-api branch January 7, 2016 00:48
@lindem lindem mentioned this pull request Jan 14, 2016
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.

Implement public API for getting options from each validation.
2 participants