Skip to content

Commit

Permalink
fix: birthdate validation to include current date
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecego committed Feb 9, 2024
1 parent 64b1f14 commit 483a727
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/validators/candidates/create_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CreateValidator < BaseValidator
def past_birtdate
return if birthdate.blank?

errors.add(:birthdate, :future_date) if birthdate > Date.current
errors.add(:birthdate, :future_date) if birthdate >= Date.current
end
end
end
6 changes: 6 additions & 0 deletions spec/validators/candidates/create_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,11 @@

it { is_expected.to be false }
end

context 'when the birthdate is today' do
before { candidate.birthdate = Date.current }

it { is_expected.to be false }
end
end
end

0 comments on commit 483a727

Please sign in to comment.