mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 09:45:11 +02:00
Fixed admin contact validation and repp error
This commit is contained in:
parent
8e8fd6cead
commit
537e75e162
4 changed files with 20 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
|||
class AdminDomainContact < DomainContact
|
||||
include AgeValidation
|
||||
|
||||
|
||||
validate :validate_contact_age
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
|
@ -33,8 +33,6 @@ class AdminDomainContact < DomainContact
|
|||
def validate_contact_age
|
||||
return unless contact&.underage?
|
||||
|
||||
errors.add(:contact, I18n.t(
|
||||
'activerecord.errors.models.admin_domain_contact.contact_too_young'
|
||||
))
|
||||
errors.add(:base, :contact_too_young)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,13 +17,17 @@ module AgeValidation
|
|||
def underage_by_birthday?
|
||||
birth_date = Date.parse(ident)
|
||||
calculate_age(birth_date) < 18
|
||||
rescue ArgumentError
|
||||
true
|
||||
end
|
||||
|
||||
def underage_by_estonian_id?
|
||||
return false unless estonian_id?
|
||||
|
||||
|
||||
birth_date = parse_estonian_id_birth_date(ident)
|
||||
calculate_age(birth_date) < 18
|
||||
rescue ArgumentError
|
||||
true
|
||||
end
|
||||
|
||||
def estonian_id?
|
||||
|
@ -50,4 +54,4 @@ module AgeValidation
|
|||
|
||||
Date.parse("#{birth_year}-#{month}-#{day}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,11 +3,10 @@ class DomainContact < ApplicationRecord
|
|||
# STI: admin_domain_contact
|
||||
include Versions # version/domain_contact_version.rb
|
||||
include EppErrors
|
||||
|
||||
belongs_to :contact
|
||||
belongs_to :domain
|
||||
|
||||
validates :contact, presence: true
|
||||
|
||||
after_destroy :update_contact
|
||||
attr_accessor :value_typeahead
|
||||
attr_writer :contact_code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue