Sha256: 9a89b5939dbd0dd147a5da4f0bb62396854699fc3e93f3d66c2fb5a61d9913b1
Contents?: true
Size: 809 Bytes
Versions: 1
Compression:
Stored size: 809 Bytes
Contents
# -*- encoding: utf-8 -*- require 'aequitas/rule' module Aequitas class Rule class Within < Rule # TODO: move options normalization into the validator macros def self.rules_for(attribute_name, options) Array(new(attribute_name, options)) end equalize_on *superclass.equalizer.keys + [:set] attr_reader :set def initialize(attribute_name, options={}) super @set = options.fetch(:set) end def valid?(resource) value = attribute_value(resource) skip?(value) || set.include?(value) end def violation_type(resource) :inclusion end def violation_data(resource) [ [ :set, set.to_a.join(', ') ] ] end end # class Within end # class Rule end # module Aequitas
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aequitas-0.0.2 | lib/aequitas/rule/within.rb |