fixed codeclimate errors

This commit is contained in:
dinsmol 2021-09-10 11:46:21 +03:00
parent 2f81e856fc
commit e345abc2fc
4 changed files with 19 additions and 20 deletions

View file

@ -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