Valida...::Date(3pm)

πŸ“¦
version 7.900059 Β· 7 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Validation::Class::Directive::Date β€” date directive for Validation Class field definitions πŸ’–

okay bestie so this is Validation::Class::Directive::Date from the User Contributed Perl Documentation corner of the universe, and it's literally the directive that does date validation for your field definitions. it's giving "core validation class field directive" energy, periodt.


✨ VERSION ✨

version 7.900059 β€” yes that's a lot of digits, she's specific like that πŸ’…


🌸 SYNOPSIS 🌸

here's the whole vibe, no cap:

use Validation::Class::Simple;

my $rules = Validation::Class::Simple->new(
    fields => {
        creation_date  => {
            date => 1
        }
    }
);

# set parameters to be validated
$rules->params->add($parameters);

# validate
unless ($rules->validate) {
    # handle the failures
}

like, you set up your rules, you add your params, you validate, and if it fails you handle the failures. iconic workflow fr fr πŸ¦‹


πŸŽ€ DESCRIPTION πŸŽ€

Validation::Class::Directive::Date is a core validation class field directive that provides validation of simple date formats. that's the whole job bestie, and she does it flawlessly 🫢

so here's the tea β€” the directive can take these options:

  • alternative argument: an-array-of-options πŸ‘‘
  • option: dmy β€” e.g. 27-12-2006 or 27-12-06
  • option: mdy β€” e.g. 12-27-2006 or 12-27-06
  • option: ymd β€” e.g. 2006-12-27 or 06-12-27
  • option: dMy β€” e.g. 27 December 2006 or 27 Dec 2006
  • option: Mdy β€” e.g. December 27, 2006 or Dec 27, 2006 (comma optional)
  • option: My β€” e.g. December 2006 or Dec 2006
  • option: my β€” e.g. 12/2006
bestie pay attention: that Mdy one? the comma is optional. so don't come for her about punctuation. πŸ’…

and the way she's flexible?? this directive can be passed a single value or an array of values. look:

fields => {
    creation_date  => {
        date => ['dmy', 'mdy']
    }
}

multiple formats in one directive?? she ate that. no notes. πŸ”₯


🌈 AUTHOR 🌈

Al Newkirk <anewkirk@ana.io> β€” the genius behind the whole thing, we stan πŸ’œ


This software is copyright (c) 2011 by Al Newkirk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in freedom bestie, go wild 🧚


okay and that's a wrap!! this page was brought to you by perl v5.36.0 and it was documented on 2023-06-11, and you read all of it, which means you're lowkey a date-validation expert now. main character energy honestly. mwah πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from