Data::FormValidator::Constraints::Dates(3pm)

Data::FormValidator::Constraints::Dates3pm

Validate dates and times

Usage

    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'),
    }

Overview

date_and_time

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:

    Y   year  (numeric)
    M   month (numeric)
    D   day   (numeric)
    h   hour
    m   minute
    s   second
    p   AM|PM

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.

Backwards compatibility

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
        },
    }

Releases

11 releases since Debian 3.1 (Sarge); the text changed 8 times.

  1. 3.1
  2. 4.0
  3. 5.0
  4. 6.0
  5. 7
  6. 8
  7. 9
  8. 10–11
  9. 12–13

Author

Mark Stosberg, <[email protected]>

Featuring clever code by Jan Krynicky.

From libdata-formvalidator-perl 4.88-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.