Sha256: ace54dcc01c50ffabda8557ebebe8b94d134fe3d14b1e9307561d5dc987e8da3

Contents?: true

Size: 626 Bytes

Versions: 12

Compression:

Stored size: 626 Bytes

Contents

module Xeroizer
  module Record
    
    class Validator
  
      class LengthOfValidator < Validator
        
        def valid?(record)
          if options[:max] && record.attributes[attribute].to_s.length > options[:max]
            record.errors << [attribute, options[:message] || "must be shorter than #{options[:max]} characters"]
          end

          if options[:min] && record.attributes[attribute].to_s.length < options[:min]
            record.errors << [attribute, options[:message] || "must be greater than #{options[:min]} characters"]
          end
        end
        
      end
  
    end
    
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
xeroizer-3.0.1 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-3.0.0 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-3-pre-beta-3.0.0.pre.beta lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.20.0 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.19.0 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.18.1 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.17.1 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.16.5 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.16.4 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.16.3 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.16.1 lib/xeroizer/record/validators/length_of_validator.rb
xeroizer-2.16.0 lib/xeroizer/record/validators/length_of_validator.rb