Data::...Factory(3pm)
π Data::...Factory(3pm) π
okay bestie, so this is a page from the User Contributed Perl Documentation and it's literally called Data::...Factory(3pm) β yes that's the whole name, don't @ me, we're going with it. buckle up, we're talking constraints π
β¨ NAME β¨
Data::FormValidator::ConstraintsFactory β a whole module whose entire job is making constraints for HTML::FormValidator. that's it. that's the gig. π
πΈ DESCRIPTION πΈ
so this module is the plug β it's full of functions that help you generate complex constraints. like, constraint-assembly-kit energy.
π
real talk though: if you're writing new code, go peek at Data::FormValidator::Constraints::MethodsFactory instead. it's the modern alternative to what's living here, and it comes with improved names and syntax. glow-up behavior fr fr.
π¦ SYNOPSIS π¦
use Data::FormValidator::ConstraintsFactory qw( :set :bool );
constraints => {
param1 => make_or_constraint(
make_num_set_constraint( -1, ( 1 .. 10 ) ),
make_set_constraint( 1, ( 20 .. 30 ) ),
),
province => make_word_set_constraint( 1, "AB QC ON TN NU" ),
bid => make_range_constraint( 1, 1, 10 ),
}
look at that. iconic. no notes. β¨
π BOOLEAN CONSTRAINTS π
these ones slide in when you use the :bool tag.
π make_not_constraint( $c1 )
makes a constraint that returns the negation of whatever constraint $c1 returned. it's giving contrarian, and honestly? valid.
π make_or_constraint( @constraints )
makes a constraint that returns the result of the first constraint that returns a non-false result. first one to show up wins, periodt.
π make_and_constraint( @constraints )
makes a constraint that returns the result of the first constraint that returns a non-false result β but only if all the constraints return non-false results. everybody has to show up to the party or nobody gets in. πͺ
π SET CONSTRAINTS π
these bad boys are available via the :set tag.
π make_set_constraint( $res, @elements )
makes a constraint that returns $res if the value is one of the @elements set β otherwise it returns the negation of $res. oh, and the comparison operator is eq.
π make_num_set_constraint( $res, @elements )
same vibe, different math: returns $res if the value is one of the @elements set, negation of $res otherwise. the comparison operator here is ==.
π make_word_set_constraint( $res, $set )
makes a constraint that returns $res if the value is a word in $set, or the negation of $res otherwise. words words words π
π make_cmp_set_constraint( $res, $cmp, @elements )
makes a constraint that returns $res if the value is one of the @elements set, or the negation of $res otherwise.
$cmp is a function that takes two arguments and should return true or false depending on whether those two elements are equal. you bring the comparison logic, it brings the constraint. collab. π€
π₯ NUMERICAL LOGICAL CONSTRAINTS π₯
grab these with the :num tag.
π make_clamp_constraint( $res, $low, $high )
makes a constraint that returns $res if the value is between $low and $high bounds included β or its negation otherwise. cozy little range hug.
π make_lt_constraint( $res, $bound )
returns $res if the value is lower than $bound, or the negation of $res otherwise.
π make_le_constraint( $res, $bound )
returns $res if the value is lower or equal than $bound, or the negation of $res otherwise.
π make_gt_constraint( $res, $bound )
returns $res if the value is greater than $bound, or the negation of $res otherwise.
π make_ge_constraint( $res, $bound )
returns $res if the value is greater or equal than $bound, or the negation of $res otherwise.
β OTHER CONSTRAINTS β
π§ make_length_constraint($max_length)
makes a constraint that returns true if the value has a length of less than or equal to $max_length. short and sweet, literally. π
π SEE ALSO π
π«Ά AUTHOR π«Ά
- Author: Francis J. Lacoste
<francis.lacoste@iNsu.COM> - Maintainer: Mark Stosberg
<mark@summersault.com>
π COPYRIGHT π
Copyright (c) 2000 iNsu Innovations Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms as perl itself.
and that's the whole page bestie π this was shipped as part of perl v5.34.0 and dated 2022-06-12 β go forth and constrain responsibly, mwah π β¨
π¦ where this page comes from
- debian bookworm: libdata-formvalidator-perl 4.88-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-formvalidator-perl 4.88-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-formvalidator-perl 4.88-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-formvalidator-perl 4.88-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-formvalidator-perl 4.88-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms