Sha256: 057fb42f285252ff369a881c30caba89fad52b208848858d7a35b11f184de203

Contents?: true

Size: 570 Bytes

Versions: 59

Compression:

Stored size: 570 Bytes

Contents

module Xeroizer
  module Record
    
    class Validator
  
      class InclusionOfValidator < Validator
        
        def valid?(record)
          if options[:in] && options[:in].is_a?(Array)            
            return true if options[:allow_blanks] && (record[attribute].nil? || record[attribute].to_s == '')
            unless options[:in].include?(record[attribute])
              record.errors << [attribute, options[:message] || "not one of #{options[:in].join(', ')}"]
            end
          end
        end
        
      end
  
    end
    
  end
end

Version data entries

59 entries across 59 versions & 3 rubygems

Version Path
xeroizer-3.0.1 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-3.0.0 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-3-pre-beta-3.0.0.pre.beta lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.20.0 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.19.0 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.18.1 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.17.1 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.16.5 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.16.4 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.16.3 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.16.1 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.16.0 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.9 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.8 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.7 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.6 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.5.2 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.5.1 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.5 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.16 lib/xeroizer/record/validators/inclusion_of_validator.rb