Sha256: 42bf7fb6c4149e69d0340b18d7ad74e21059d00a372fe8dda00852f1ead2aa5c

Contents?: true

Size: 422 Bytes

Versions: 1

Compression:

Stored size: 422 Bytes

Contents

ValidationError = require "hoarder/validator/error/validation_error"

#
# @author - Tim Shelburne <tim@musiconelive.com>
#
# 
#
class EmailConstraint
  canHandle: (type)->
    type is "email"

  handle: (element)->
    if element.value.match(/^([a-zA-Z0-9_-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,4})$/i)
      return []
    else
      return [ new ValidationError "Please enter a valid email address." ]

return EmailConstraint

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hoarder-js-0.0.1 assets/scripts/coffee/hoarder/validator/constraints/email_constraint.coffee