Sha256: 0e4caf56a5ec02169a202e13e699695231a1c4f2f853820dae1a0fec55530e6f

Contents?: true

Size: 401 Bytes

Versions: 7

Compression:

Stored size: 401 Bytes

Contents

I18n.backend.store_translations :nl, errors: {
  messages: { subset: 'bevat onbekende keuzes' }
}

class SubsetValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return unless value
    unless value.all? { |element| options.fetch(:of).include? element }
      record.errors.add attribute, (options[:message] || I18n.t('errors.messages.subset'))
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roqua-support-0.4.6 lib/roqua/validators/subset_validator.rb
roqua-support-0.4.5 lib/roqua/validators/subset_validator.rb
roqua-support-0.4.4 lib/roqua/validators/subset_validator.rb
roqua-support-0.4.3 lib/roqua/validators/subset_validator.rb
roqua-support-0.4.2 lib/roqua/validators/subset_validator.rb
roqua-support-0.4.1 lib/roqua/validators/subset_validator.rb
roqua-support-0.4.0 lib/roqua/validators/subset_validator.rb