return false if groups is null
groups[0] is input
emailRE = new RegExp("[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?")
translate = (field, memo, isInteger) ->
try
result = parseNumber memo.value, isInteger
if _.isNaN result
throw messages "core-input-not-numeric"
memo.translated = result
catch e
memo.error = (field.attr "data-translation-message") or e.message or "ERROR"
return false
dom.onDocument events.field.optional, "[data-optionality=required]", (event, memo) ->
if utils.isBlank memo.value
memo.error = (@attr "data-required-message") or "REQUIRED"
dom.onDocument events.field.translate, "[data-translation=numeric]", (event, memo) ->
translate this, memo, false
dom.onDocument events.field.translate, "[data-translation=integer]", (event, memo) ->
translate this, memo, true
dom.onDocument events.field.validate, "[data-validate-min-length]", (event, memo) ->
min = parseInt @attr "data-validate-min-length"
if memo.translated.length < min
memo.error = (@attr "data-min-length-message") or "TOO SHORT"
return false
dom.onDocument events.field.validate, "[data-validate-max-length]", (event, memo) ->
max = parseInt @attr "data-validate-max-length"
if memo.translated.length > max
memo.error = (@attr "data-max-length-message") or "TOO LONG"
return false
dom.onDocument events.field.validate, "[data-validate-max]", (event, memo) ->
max = parseInt @attr "data-validate-max"
if memo.translated > max
memo.error = (@attr "data-max-message") or "TOO LARGE"
return false
dom.onDocument events.field.validate, "[data-validate-min]", (event, memo) ->
min = parseInt @attr "data-validate-min"
if memo.translated < min
memo.error = (@attr "data-min-message") or "TOO SMALL"
return false
dom.onDocument events.field.validate, "[data-validate-email]", (event, memo) ->
unless (matches memo.translated, emailRE)
memo.error = (@attr "data-email-message") or "INVALID EMAIL"
return false
dom.onDocument events.field.validate, "[data-validate-regexp]", (event, memo) ->