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