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