Sha256: 6ab66d9802592f6c7967c7c763ece84e73587710b8af5e5aff38ee2e26a904c7
Contents?: true
Size: 660 Bytes
Versions: 184
Compression:
Stored size: 660 Bytes
Contents
# -*- encoding : utf-8 -*- class CuracaoIdNumberValidator < ActiveModel::EachValidator 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] || "not a valid date" ) end else record.errors.add(attribute.to_sym, options[:message] || "is not a number" ) end end end #"moet bestaan uit tien cijfers (bijvoorbeeld 1983040812)." #"moet een datum zijn."
Version data entries
184 entries across 184 versions & 1 rubygems