How to extend existing validators? #111

andriijas opened this Issue Mar 4, 2013 · 2 comments

2 participants



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?


  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

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.


Okay cool thanks.

@thedersen thedersen added a commit that referenced this issue Oct 31, 2013
@thedersen Fixed undefined format function when calling one of the built in
validators form within a method validator. Fixes #98 and #111
@thedersen thedersen closed this Nov 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment