Sha256: 9bacc9b0e876aa8d2fbe2e493f97f2daa62c1b3e9e8d47fa50cf468c14442619

Contents?: true

Size: 713 Bytes

Versions: 20

Compression:

Stored size: 713 Bytes

Contents

class App.Validators.Vulgarity extends App.Validators.Base
  @identity = 'Vulgarity'

  constructor: -> super

  validate: ->
    return if not @val?
    switch typeof @val
      when 'string'
        vulgarWord = this._getVulgarWord()
        if ///#{vulgarWord}///i.exec @val
          this._addErrorMessage()
        else
          return
      else
        throw new TypeError "Vulgarity validator is applicable only for strings and #{@attr} isn't."

  _addErrorMessage: ->
    message = App.I18n[App.Env.loco.getLocale()].errors.messages.vulgarity
    @obj.addErrorMessage message, for: @attr

  _getVulgarWord: ->
    switch App.Env.loco.getLocale()
      when 'pl' then 'kurwa'
      when 'en' then 'fuck'

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.5.3 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.5.2 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-3.0.2 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-3.0.1 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.5.1 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.5.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.4.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.3.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-3.0.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.2.2 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.2.1 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.2.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.1.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-2.0.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-1.5.2 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-1.5.1 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-1.5.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-1.4.0 test/dummy/app/assets/javascripts/validators/vulgarity.coffee
loco-rails-1.3.3 test/dummy/app/assets/javascripts/validators/vulgarity.coffee