Sha256: 5c28ebd835f3ed279cdb5b6570284ed6a77c965a0935f28e66dcc4deb4c9088f

Contents?: true

Size: 540 Bytes

Versions: 4

Compression:

Stored size: 540 Bytes

Contents

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

class Presence extends Base
  @identity = "Presence"

  constructor: -> super()

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

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

export default Presence

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/presence.coffee
loco-rails-3.0.2 test/dummy/node_modules/loco-js-model/src/validators/presence.coffee
loco-rails-3.0.1 test/dummy/node_modules/loco-js-model/src/validators/presence.coffee
loco-rails-3.0.0 test/dummy/node_modules/loco-js-model/src/validators/presence.coffee