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

How to extend existing validators? #111

Closed
andriijas opened this issue Mar 4, 2013 · 2 comments
Closed

How to extend existing validators? #111

andriijas opened this issue Mar 4, 2013 · 2 comments

Comments

@andriijas
Copy link

Hi

Im trying to extend existing validator but I get typeerror because of wrong scope

Is there any way I can do this so that it works?
How would I extend the default set of validators to add this so that I can use it in other places in my app?

Thanks

  multipleEmails: (value, attr, computedState) ->
    emails =  if value then value.split(',') else []
    for email in emails
      foo = Backbone.Validation.validators.pattern email, attr, 'email', @
      return "#{attr} must contain a comma separated list of emails" unless foo
    ''
@thedersen
Copy link
Owner

This is a bug. You can get around it by not calling the built-in validator(s) from a custom, and just copy the code.

@andriijas
Copy link
Author

Okay cool thanks.

thedersen added a commit that referenced this issue Oct 31, 2013
validators form within a method validator. Fixes #98 and #111
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