mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
fixed codeclimate errors
This commit is contained in:
parent
2f81e856fc
commit
e345abc2fc
4 changed files with 19 additions and 20 deletions
|
@ -1,7 +1,4 @@
|
|||
class Contact::Ident::BirthDateValidator < ActiveModel::Validator
|
||||
VALID_BIRTH_DATE_FROM = Time.zone.today - 150.years
|
||||
VALID_BIRTH_DATE_TO = Time.zone.tomorrow
|
||||
|
||||
def validate(record)
|
||||
record.errors.add(:code, :invalid_birth_date) if birth_date_wrong?(record)
|
||||
end
|
||||
|
@ -18,7 +15,9 @@ class Contact::Ident::BirthDateValidator < ActiveModel::Validator
|
|||
end
|
||||
|
||||
contact_ident_date = Date.parse(record.code)
|
||||
valid_time_range = VALID_BIRTH_DATE_FROM...VALID_BIRTH_DATE_TO
|
||||
date_from = Time.zone.today - 150.years
|
||||
date_to = Time.zone.tomorrow
|
||||
valid_time_range = date_from...date_to
|
||||
return if valid_time_range.cover?(contact_ident_date)
|
||||
|
||||
true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue