Sha256: 941c3f4ae2440841fd95b6f7b6aac739829503bb95d75632b568b9648bba9641
Contents?: true
Size: 623 Bytes
Versions: 6
Compression:
Stored size: 623 Bytes
Contents
# -*- encoding : utf-8 -*- class IsACuracaoIdNumberValidator < InlineFormsValidator def validate_each(record, attribute, value) if value =~ /^[0-9]{10}$/ year = value[0..3].to_i month = value[4..5].to_i day = value[6..7].to_i number= value[8..9].to_i begin DateTime.civil(year, month, day) rescue ArgumentError record.errors.add(attribute.to_sym, options[:message] || "too_short" ) end else record.errors.add(attribute.to_sym, options[:message] || "not_a_number" ) end end end #"moet bestaan uit tien cijfers (bijvoorbeeld 1983040812)."
Version data entries
6 entries across 6 versions & 1 rubygems