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

Version Path
inline_forms-6.2.14 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.12 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.11 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.10 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.9 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.7 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.6 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.5 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.4 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.3 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.2 app/validators/curacao_id_number_validator.rb
inline_forms-6.2.1 app/validators/curacao_id_number_validator.rb
inline_forms-6.1.1 app/validators/curacao_id_number_validator.rb
inline_forms-6.1.0 app/validators/curacao_id_number_validator.rb
inline_forms-6.0.8 app/validators/curacao_id_number_validator.rb
inline_forms-6.0.7 app/validators/curacao_id_number_validator.rb
inline_forms-6.0.6 app/validators/curacao_id_number_validator.rb
inline_forms-6.0.5 app/validators/curacao_id_number_validator.rb
inline_forms-6.0.4 app/validators/curacao_id_number_validator.rb
inline_forms-6.0.3 app/validators/curacao_id_number_validator.rb