Sha256: 5700e56efbd96821bd31e07b10e1153a43d82d73f57ec5867ef764dde3b9d4ba
Contents?: true
Size: 745 Bytes
Versions: 36
Compression:
Stored size: 745 Bytes
Contents
# -*- encoding : utf-8 -*- # == usage: # in your model, add: # validates :id_number, must_be_present => true, is_a_curacao_id_number => true; class IsACuracaoIdNumberValidator < 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] || "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
36 entries across 36 versions & 1 rubygems