8000 How to extend existing validators? · Issue #111 · thedersen/backbone.validation · GitHub
[go: up one dir, main page]

Skip to content 8000
How to extend existing validators?  #111
@andriijas

Description

@andriijas

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
    ''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0