Sha256: d5a32ba2ad5b012b7843ef3c231b96e3052677a693e0300ca35108b6115034db

Contents?: true

Size: 504 Bytes

Versions: 4

Compression:

Stored size: 504 Bytes

Contents

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

class Exclusion extends Base
  @identity = "Exclusion"

  constructor: -> super()

  validate: ->
    set = @opts.in or @opts.within or []
    return if set.indexOf(@val) is -1
    this._addErrorMessage()

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

export default Exclusion

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