assets/scripts/coffee/hoarder/validator/constraints/email_constraint.coffee in hoarder-js-0.0.1 vs assets/scripts/coffee/hoarder/validator/constraints/email_constraint.coffee in hoarder-js-0.0.2
- old
+ new
@@ -1,18 +1,12 @@
-ValidationError = require "hoarder/validator/error/validation_error"
+BaseConstraint = require 'hoarder/validator/constraints/base_constraint'
-#
-# @author - Tim Shelburne <tim@musiconelive.com>
-#
-#
-#
-class EmailConstraint
- canHandle: (type)->
- type is "email"
+class EmailConstraint extends BaseConstraint
+
+ constructor: ->
+ @type = "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." ]
+ rulePasses: (element)-> element.value.match(/^([a-zA-Z0-9_-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,4})$/i)
+
+ errorMessage: -> "Please enter a valid email address."
return EmailConstraint
\ No newline at end of file