Sha256: ce7a52121e9f1c745b4a325006d488f0351a8f0e60aa95e39607cf00362ede69

Contents?: true

Size: 413 Bytes

Versions: 1

Compression:

Stored size: 413 Bytes

Contents

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

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

  handle: (element)->
    if element.value.match(/^\d?[.(\-]?\d\d\d[.)\-]?\d\d\d[.\-]?\d\d\d\d$/)
      return []
    else
      return [ new ValidationError "Please enter a valid phone number." ]

return PhoneConstraint

Version data entries

1 entries across 1 versions & 1 rubygems

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