[html-formfu] Correct date constraint?
Octavian Rasnita
orasnita at gmail.com
Mon Feb 15 18:36:28 GMT 2010
From: "Carl Franks" <fireartist at gmail.com>
On 5 February 2010 16:02, Octavian Rasnita <orasnita at gmail.com> wrote:
>> Hi,
>>
>> Does HTML::FormFu offer a way of using a constraint that disallows
>> sending
>> invalid dates like February 30?
>
> HTML::FormFu::Constraint::DateTime should work fine for this.
>
> Carl
Hi,
I think that Date and DateTime fields should use by default the DateTime
constraint, or any other constraint that assures that the chosen date is
valid.
I have checked the DateTime constraint, (I want to use it with Date and
DateTime fields) but it requires too much code.
In the DateTime fields, I use something like:
strftime %Y-%m-%d %H:%M:00
but for using the DateTime constraint, I should define this format a second
time for each field, and use strptime instead of strftime.
I think the DateTime and Date fields should use by default the DateTime
constraint because those fields should always send correct date values.
I put the following in the myapp.pl Catalyst configuration file which sets
this constraint for all the DateTime elements, but it would be nice if it
wouldn't be necessary:
'Controller::HTML::FormFu' => {
constructor => {
default_args => {
elements => {
DateTime => {
constraints => [
{
type => 'DateTime',
parser => {strptime => '%Y-%m-%d %H:%M:00'},
},
],
},
},
},
},
},
Thanks.
Octavian
More information about the HTML-FormFu
mailing list