Remove unneeded rescue from DOB Validator (#37785)

This commit is contained in:
Matt Jankowski
2026-02-10 16:24:23 +00:00
committed by GitHub
parent 63aac77b61
commit 66b09318ed
2 changed files with 1 additions and 3 deletions
@@ -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