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-float-2.15.3.15 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.14 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.13 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.12 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.11 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.10 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.9 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.8 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.7 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.6 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.5 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.4 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.3 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.2 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-float-2.15.3.1 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.3 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.2 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.1 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-2.15.0 lib/xeroizer/record/validators/inclusion_of_validator.rb
xeroizer-0.5.2 lib/xeroizer/record/validators/inclusion_of_validator.rb