failure = true
if _.isString memo.error
@trigger events.field.showValidationError, { message: memo.error }
@trigger events.field.optional, memo
postEventTrigger()
unless failure or (utils.isBlank memo.value)
@trigger events.field.translate, memo
postEventTrigger()
unless failure
if _.isUndefined memo.translated
memo.translated = memo.value
@trigger events.field.validate, memo
postEventTrigger()
if failure
formMemo.error = true
this.attr('aria-invalid', 'true');
this.attr('aria-describedby', this.attr('id') + "-help-block");
else
this.attr('aria-invalid', 'false');
this.attr('aria-describedby ', null);
@trigger events.field.clearValidationError
return
dom.onDocument events.field.clearValidationError, ->
blocks = exports.findHelpBlocks this
for block in blocks or []
block.hide().update("")
block.parent().removeClass "has-error"
block.attr("role", null)
group = @findParent ".form-group"
group and group.removeClass "has-error"
return
dom.onDocument events.field.showValidationError, (event, memo) ->
blocks = exports.findHelpBlocks this
unless blocks
blocks = [exports.createHelpBlock this]
for block in blocks
block.removeClass("invisible").show().update(memo.message)