Remove unneeded rescue from DOB Validator (#37785)
This commit is contained in:
parent
63aac77b61
commit
66b09318ed
@ -3,8 +3,6 @@
|
||||
class DateOfBirthValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
record.errors.add(attribute, :below_limit) if value.present? && value.to_date > min_age.ago
|
||||
rescue Date::Error
|
||||
record.errors.add(attribute, :invalid)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@ -10,7 +10,7 @@ RSpec.describe DateOfBirthValidator do
|
||||
context 'with an invalid date' do
|
||||
let(:invalid_date) { '76.830.10' }
|
||||
|
||||
it { is_expected.to_not allow_values(invalid_date).for(:date_of_birth) }
|
||||
it { is_expected.to_not allow_values(invalid_date).for(:date_of_birth).with_message(:blank) }
|
||||
end
|
||||
|
||||
context 'with a date below the age limit' do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user