[html-formfu] DateTime constraint fails? (aka how do I make it a scalar reference?)

Matija Grabnar matija at serverflow.com
Wed Mar 18 11:31:30 GMT 2009


Carl Franks wrote:
> 2009/3/17 Matija Grabnar <matija at serverflow.com>:
>   
>> Given the constraint:
>>
>>    - type: Text
>>      name: start
>>      label: From
>>      attributes:
>>        class: date
>>      constraints:
>>        - type: DateTime
>>          parser:
>>            regex: '^\s*(\d{4})-(\d{2})-(\d{2})\s*\d{0,2}:\d{2}:\d{2}\s*$'
>>            params: [ year, month, day ]
>>
>> I get the error:
>>
>> Caught exception in MyApp::Controller::Root->edit "The 'regex' parameter
>> ("^\s*(\d{4})-(\d{2})-(\d{2})\s*\d{0,2}:\d{2}:\d{2}\s*$") to
>> DateTime::Format::Builder::Parser::create_single_parser was a 'scalar',
>> which is not one of the allowed types: scalarref
>>
>> Any ideas on what I may be doing wrong? I tried googling it, but got nothing
>> that seemed like a solution.
>>     
>
> Hmm, maybe it only accepts an actual regex object, and not a string.
> Try this in your config:
>   regex: !!perl/regexp (^\s*(\d{4})-(\d{2})-(\d{2})\s*\d{0,2}:\d{2}:\d{2}\s*$)
>   
The string you gave me complained about "unmatched ) in regex". However,
replacing the first ( and the last ) with a / gave me a working regex.

Thank you!

Can I suggest that someone should change the documentation for 
Constraint::DateTime?



More information about the HTML-FormFu mailing list