Closed phlegx closed 9 years ago
I have solved the problem by adding the following line in the config:
ValidatesTimeliness.setup do |config|
config.use_plugin_parser = true
config.parser.add_formats(:datetime, 'dd.mm.yyyy, hh:nn')
end
Yep you got it. Type casting and validation are not the same thing. Typecasting should any valid value. The validation should block the valid acceptance of a value for more specific reasons e.g. in comparison to another value or, in your case a specific format.
Using the following validation:
The validation returns an error that the attribute must be set. This is caused by the method
timeliness_type_cast_code(attr_name, var_name)
in file https://github.com/johncarney/validates_timeliness/blob/master/lib/validates_timeliness/attribute_methods.rb#L65The
Timeliness::Parser.parse()
call ignores the:format
option set in the validation.Any idea how t add
:format
option dynamically toTimeliness::Parser.parse()
?!