Sha256: d3da8ad2b22214d3547319a6881613ecf30bb9c736d413d03dd0485a8e299a61

Contents?: true

Size: 265 Bytes

Versions: 8

Compression:

Stored size: 265 Bytes

Contents

# frozen_string_literal: true
class SubsetValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    superset = options[:of]
    rest = value - superset
    record.errors.add(attribute, :subset, **options) unless rest.empty?
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 app/validators/subset_validator.rb
shipit-engine-0.38.0 app/validators/subset_validator.rb
shipit-engine-0.37.0 app/validators/subset_validator.rb
shipit-engine-0.36.1 app/validators/subset_validator.rb
shipit-engine-0.36.0 app/validators/subset_validator.rb
shipit-engine-0.35.1 app/validators/subset_validator.rb
shipit-engine-0.35.0 app/validators/subset_validator.rb
shipit-engine-0.34.0 app/validators/subset_validator.rb