Sha256: 5035ad4a5660c7dac2e543b49ceae38dae3fc54cd9ac50a702dd8c5270568f14

Contents?: true

Size: 544 Bytes

Versions: 4

Compression:

Stored size: 544 Bytes

Contents

import Base from './base.coffee'
import I18n from '../i18n'
import Config from '../config'

class Absence extends Base
  @identity = "Absence"

  constructor: -> super()

  validate: ->
    switch typeof @val
      when 'string'
        return if @val? and @val.length is 0
      else
        return if not @val?
    this._addErrorMessage()

  _addErrorMessage: ->
    message = if @opts.message?
      @opts.message
    else
      I18n[Config.locale].errors.messages.present
    @obj.addErrorMessage message, for: @attr

export default Absence

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/node_modules/loco-js-model/src/validators/absence.coffee
loco-rails-3.0.2 test/dummy/node_modules/loco-js-model/src/validators/absence.coffee
loco-rails-3.0.1 test/dummy/node_modules/loco-js-model/src/validators/absence.coffee
loco-rails-3.0.0 test/dummy/node_modules/loco-js-model/src/validators/absence.coffee