Sha256: 5ac24eb7a07a517de75ff9b2bc3c4fe95be9fdb9ea5cea3fc3178fdaf37b6adc

Contents?: true

Size: 434 Bytes

Versions: 1

Compression:

Stored size: 434 Bytes

Contents

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

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

  handle: (element)->
    if element.value.match(/^[A-Za-z0-9\s]*$/)
      return []
    else
      return [ new ValidationError "This field only accepts numbers and characters (0-9, A-Z, a-z)." ]

return AlphanumericConstraint

Version data entries

1 entries across 1 versions & 1 rubygems

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