Sha256: 50d6885d789525d682a0df563a3ef5b7a2a4f1b2078ef4331053ed5a4e9e3fa7
Contents?: true
Size: 668 Bytes
Versions: 102
Compression:
Stored size: 668 Bytes
Contents
class FileuidValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if options[:allow_nil] && value.presence.nil? if value.is_a?(EgovUtils::Fileuid) record.errors.add(attribute, (options[:message] || :fileuid_format)) if value.invalid? elsif !match_regexp?(record, attribute, value) record.errors.add(attribute, (options[:message] || :fileuid_format)) end end def match_regexp?(record, attribute, value) type = nil if type value =~ EgovUtils::Fileuid::TYPES[type].to_regex else EgovUtils::Fileuid::TYPES.values.any?{|type_def| value =~ type_def.to_regex } end end end
Version data entries
102 entries across 102 versions & 1 rubygems