Comments (10)
I suppose my thought was that AM and an hour > 12 is contradictory. Though both are invalid meridian times.
There is no option to change this behaviour, it requires a code change. For the v3 it requires a change to the Timeliness gem, which is not great problem.
Which version of the plugin are you using?
from validates_timeliness.
I'm using 3.0.5 of validates_timeliness and 0.3.3 of timeliness.
PM and hour > 12 should be contradictory too, no?
from validates_timeliness.
Yes, perhaps.
I went to add a failing spec in Timeliness to test the behaviour and it should currently return a nil value. This is because it will try to make a time instance with an hour of 13 + 12 (for PM) which will throw an error.
Can you give me a failing spec for this?
from validates_timeliness.
I can't figure it out. I've tried to make a failing spec in both timeliness and validates_timeliness, and neither one will make a time from "13:00pm." I made this test in validator_spec:
it "is a test" do
person.birth_datetime = "13:00pm"
person.invalid?
person.birth_datetime.should eql(52)
person.errors[:birth_datetime].should_not be_empty
end
and inserted it at line 134. person.invalid? does not fail (same results with person.valid?), but person.birth_datetime.should eql(52) tells me that birth_datetime is nil. However, on my own testing with a model that has validates_datetime for :departure, and with b.departure = "13:00pm", using b.departure.to_s gives me 2011-02-16 13:00:00 UTC.
Any ideas?
from validates_timeliness.
I made the smallest rails app I could to try and isolate the problem, and with only one model that has only a datetime and no other gems added to the Gemfile except validates_timeliness, I can assign "13:00pm" to my model and it turns into "13:00:00."
I uploaded it here: https://github.com/vhalis/validates_datetime-Meridian-PM-times
I'm really not sure what's going on, sorry. :(
from validates_timeliness.
I think the problem is that you don't have the plugin parser turned on. This is done in the config initializer output by the generator. You are possibly seeing the regular time parsing of this value.
from validates_timeliness.
I ran the generator for the install and uncommented the config.use_plugin_parser and set it to true. However, the test still has the same result. Also pushed new version to github.
from validates_timeliness.
I've tracked it down to the railtie not loading the ActiveRecord extension by default, meaning the parser was not being used. If you uncomment the config.extend_orms [ :active_record ] line in the initializer it works as expected.
Will look into a fix.
from validates_timeliness.
Closing this and opening a new issue with description pointing here.
from validates_timeliness.
Thanks a bunch, things work as expected with that. Thanks for your time!
from validates_timeliness.
Related Issues (20)
- No configuration required per thread (compatibility with timeliness 0.4.0+ HOT 7
- No support for midnight with :time type HOT 1
- NoMethodError: undefined method `deduplicate' with ActiveRecord 6.1 HOT 3
- Doesn't work with Ruby 3.0 / Rails 6.1 (PR attached) HOT 5
- Gem in 5.0.0 version not execute "timeliness" validations in ActiveRecord models HOT 12
- Update `CHANGELOG.rdoc` for v5.0.0 HOT 1
- Check time_zone_aware_types HOT 3
- Plans to release a official 6.x version HOT 3
- `add_error` call with wrong number of arguments HOT 2
- Issue on engine test load HOT 2
- ArgumentError: wrong number of arguments (given 3, expected 1..2) on records.error.add HOT 8
- Locale for Vietnamese HOT 2
- Rails 7 Deprecation Warnings HOT 6
- Rails 7 dependency - activemodel HOT 4
- Please support Rails 7 then cut a new version HOT 1
- Additional maintainer needed HOT 2
- Support for Rails 7 HOT 4
- Is there any way that I can make sure that ranges are exclusive?
- Handle when the passed value is not a Date value. when it's a Numeric
- Comparison to ComparisonValidator HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from validates_timeliness.