mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
created birth date validator
This commit is contained in:
parent
33a855fbe7
commit
addeebfeb3
6 changed files with 32 additions and 34 deletions
|
@ -8,9 +8,6 @@ class Epp::Contact < Contact
|
|||
# disable STI, there is type column present
|
||||
self.inheritance_column = :sti_disabled
|
||||
|
||||
VALID_BIRTH_DATE_FROM = Time.zone.today - 150.years
|
||||
VALID_BIRTH_DATE_TO = Time.zone.tomorrow
|
||||
|
||||
before_validation :manage_permissions
|
||||
|
||||
def manage_permissions
|
||||
|
@ -19,28 +16,6 @@ class Epp::Contact < Contact
|
|||
throw(:abort)
|
||||
end
|
||||
|
||||
validate :validate_birthday_ident
|
||||
|
||||
def validate_birthday_ident
|
||||
return unless Depp::Contact::SELECTION_TYPES[2].include?(ident_type)
|
||||
|
||||
begin
|
||||
Date.parse(ident)
|
||||
rescue ArgumentError
|
||||
add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.valid_ident_date_format'))
|
||||
@error = true
|
||||
return
|
||||
end
|
||||
|
||||
contact_ident_date = Date.parse(ident)
|
||||
valid_time_range = VALID_BIRTH_DATE_FROM...VALID_BIRTH_DATE_TO
|
||||
return if valid_time_range.cover?(contact_ident_date)
|
||||
|
||||
add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.valid_ident_date_range'))
|
||||
@error = true
|
||||
nil
|
||||
end
|
||||
|
||||
class << self
|
||||
# support legacy search
|
||||
def find_by_epp_code(code)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue