-
Notifications
You must be signed in to change notification settings - Fork 235
Open
Description
I have instances where I need to validate other formats, mm/dd/yyyy or dd/mm/yyyy for example.
Those formats never seem to validate with this gem.
I added the following context to spec/validates_timeliness/validator/format_spec.rb under the date type, and it fails the specs on the gem.
context "when the format is dd/mm/yyyy" do
before do
Person.validates_date :birth_date, format: "dd/mm/yyyy"
end
it "should be valid for string given in the right format" do
valid!(:birth_date, '23/12/2023')
end
it "should not be valid for string given in the wrong format" do
invalid!(:birth_date, '2023-12-23', /is not a valid date/)
end
it "should be valid for date instance" do
valid!(:birth_date, Date.new(2022,12,23))
end
end
Failure/Error: expect(record).to be_valid
expected `#<Person:0x0000000109337f20 @attributes=#<ActiveModel::AttributeSet:0x0000000109337ea8 @attributes={"...Model::Error attribute=birth_date, type=invalid_date, options={:message=>nil, :restriction=>nil}>]>>.valid?` to be truthy, got false
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels