adzap / validates_timeliness

Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
MIT License
1.59k stars 227 forks source link

Gem in 5.0.0 version not execute "timeliness" validations in ActiveRecord models #196

Closed pedrofurtado closed 1 year ago

pedrofurtado commented 3 years ago

Hi @adzap ! 👋

We was using Rails 6.1.3.1 with validates_timeliness in version 4.1.1. Everything worked well 🍻

After upgrade the gem to 5.0.0, the timeliness-specific validations is not executed.

# With Rails 6.1.3.1 + validates_timeliness 4.1.1 = works well
class Person < ApplicationRecord
  validates :birthday, presence: true, timeliness: { on_or_before: :today, type: :date }
end
# With Rails 6.1.3.1 + validates_timeliness 5.0.0 = timeliness-specific validation not triggered
class Person < ApplicationRecord
  validates :birthday, presence: true, timeliness: { on_or_before: :today, type: :date }
end
pedrofurtado commented 3 years ago

c/c: @willradi @leonardocomar

adzap commented 3 years ago

@pedrofurtado are you able to share you ValidatesTimeliness initializer?

Also, the version should match the major Rails version you are using. v5 is meant for Rails v5.x compat. The v6 alpha went out yesterday and is going to the version were any Rails v6.x issues are addressed.

pedrofurtado commented 3 years ago

My initializer has this code:

# config/initializers/validates_timeliness.rb

ValidatesTimeliness.setup do |config|
  config.extend_orms = [:active_record]
end
adzap commented 3 years ago

Can you add in this line and see if it makes any difference

config.parser.use_us_formats

pedrofurtado commented 3 years ago

@adzap I think it's better to wait a official release of 6.x version of gem. We upgraded, for testing, the gem to 6.0.0.alpha1 and everything worked well 🎉

Is there some planning to release a official 6.x version soon, @adzap ? 🤝 🍻

adzap commented 3 years ago

I imagine beta version would soon. Final depends on any issues and confirmed usage. I have no Rails 6 projects yet so I won't be using that version at the moment.

pedrofurtado commented 3 years ago

@adzap We have tried 6.x alpha version here in our Rails6 app and it's working well. Is there any planning to release the official 6.x version soon? 🎉 🍻

adzap commented 3 years ago

@pedrofurtado yep soon. once I have some feedback from others.

WillRadi commented 3 years ago

Hello guys! I have a Rails 6 app with 6.x-alpha version and it's working too. Just waiting for the release.. o/

LeonardoComar commented 3 years ago

Hi! In my application Rails 6 wiith 6.x-alpha version, it's working very well 👍

pedrofurtado commented 3 years ago

@adzap We are using gem in 6.0.0.alpha1 for several weeks, in three different Rails apps in production, and I confirm that it is stable enough 👍 Happy to see a official release of 6.x, to upgrade in our Rails app here 🤝 🍻

pedrofurtado commented 3 years ago

Any news about it? 🤝 🍻