GithubHelp home page GithubHelp logo

Comments (7)

adzap avatar adzap commented on July 17, 2024

Do you have the use_plugin_parser config option set to true?

from validates_timeliness.

huug avatar huug commented on July 17, 2024

Thanks for helping!

I have set the use_plugin_parser config option to true and 'Invalid date' exception is gone.

The shim however still does not work, so the date is blanked out.

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

Do you mean the date is nil? If so, that is the intended behavior.

On 12/09/2011, at 8:30 PM, Hugues [email protected] wrote:

Ok, I have set the use_plugin_parser config option to true and 'Invalid date' exception is gone.
The shim however still does not work, so the date is blanked out.

Reply to this email directly or view it on GitHub:
#53 (comment)

from validates_timeliness.

huug avatar huug commented on July 17, 2024

Ok. But what about the 'shim' explained in the README?

Specifically, when you assign an invalid date/time value to an attribute, most ORM/ODMs will only store a nil value for the attribute. This causes an issue for date/time validation, since we need to know that a value was assigned but was invalid. To fix this, we need to cache the original invalid value to know that the attribute is not just nil.

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

It's is cached internally which is why you invalid date instead 'date cannot be empty' message. The plugin can tell when tried write a value to the attribute.

On 12/09/2011, at 11:28 PM, Hugues [email protected] wrote:

Ok. But what about the 'shim' explained in the README?

Specifically, when you assign an invalid date/time value to an attribute, most ORM/ODMs will only store a nil value for the attribute. This causes an issue for date/time validation, since we need to know that a value was assigned but was invalid. To fix this, we need to cache the original invalid value to know that the attribute is not just nil.

Reply to this email directly or view it on GitHub:
#53 (comment)

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

I'm closing this since I think the issue is clear now. You would never want the invalid value to be returned from a the regular attribute method, it should always be the parsed value or nil from a failed parse. You can get the raw value using the _timeliness_raw_value_for(attr_name) method in mongoid. The ActiveRecord shim allows the <attr_name>_before_type_cast method for date/time attributes to get access to raw values.

from validates_timeliness.

huug avatar huug commented on July 17, 2024

Ok, I think I misunderstood the part about the 'shim'. Thanks!

from validates_timeliness.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.