Data::FormValidator::CUserrContribData::FormValidator::Constraints::Dates(3pm)
Data::FormValidator::Constraints::Dates - Validate Dates and Times
| Use Case | Command | Description |
|---|---|---|
| Validate date/time with format string | date_and_time('MM/DD/YYYY hh:mm:ss pp') | Validates input against the given format, including AM/PM. |
| Validate date only | date_and_time('YYYY-MM-DD') | Validates a date in ISO format. |
| Custom format with alternatives | date_and_time('MM?/DD?/YYYY|YYYY-MM?-DD?') | Allows multiple date formats using Perl-like regex in the format string. |
use Data::FormValidator::Constraints::Dates qw(date_and_time);
# In a DFV profile...
constraint_methods => {
# 'pp' denotes AM|PM for 12 hour representation
my_time_field => date_and_time('MM/DD/YYYY hh:mm:ss pp'),
}
Note: This is a new module is a new addition to Data::FormValidator and is should be considered "Beta".
This constraint creates a regular expression based on the format string passed in to validate your date against. It understands the following symbols:
Other parts of the string become part of the regular expression, so you can do perlish things like this to create more complex expressions:
'MM?/DD?/YYYY|YYYY-MM?-DD?'
Internally Date::Calc is used to test the functions.
This older, more awkward interface is supported:
# In a Data::FormValidator Profile:
validator_packages => [qw(Data::FormValidator::Constraints::Dates)],
constraints => {
date_and_time_field => {
constraint_method => 'date_and_time',
params=>[\'MM/DD/YYYY hh:mm:ss pp'], # 'pp' denotes AM|PM for 12 hour representation
},
}
Mark Stosberg, <mark AT summersault.com>
Featuring clever code by Jan Krynicky.
Copyright 2003-2005 by Mark Stosberg
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.26.1 Data::FormValidator::Constraints::Dates(3pm)
Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-25 05:18 @216.73.216.179
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)