Sha256: 264737cb87ce7b8cdd848df273efe98fa56da45d84575fadfaedc70eb67ce742

Contents?: true

Size: 386 Bytes

Versions: 1

Compression:

Stored size: 386 Bytes

Contents

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

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

  handle: (element)->
    if element.value.match(/^[0-9]*$/)
      return []
    else
      return [ new ValidationError "This field only accepts numbers (0-9)." ]

return NumericConstraint

Version data entries

1 entries across 1 versions & 1 rubygems

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