man > Data::FormValidator::ConstraintsFactory

Data::FormValidator::ConstraintsFactory(3pm)

📛 NAME

Data::FormValidator::ConstraintsFactory - Module to create constraints for HTML::FormValidator.

🚀 Quick Reference

Use CaseCommandDescription
Negate a constraintmake_not_constraint($c1)Returns the negation of constraint $c1
Combine constraints with ORmake_or_constraint(@constraints)Returns result of first true constraint
Combine constraints with ANDmake_and_constraint(@constraints)Returns true only if all constraints are true
Check value against a set (string equality)make_set_constraint($res, @elements)Returns $res if value is in @elements, else negation
Check value against a set (numeric equality)make_num_set_constraint($res, @elements)Returns $res if value is in @elements using ==
Check value against a word setmake_word_set_constraint($res, $set)Returns $res if value is a word in $set
Check value against a set with custom comparatormake_cmp_set_constraint($res, $cmp, @elements)Returns $res if value is in @elements using $cmp
Clamp value between low and highmake_clamp_constraint($res, $low, $high)Returns $res if value is between $low and $high inclusive
Less than boundmake_lt_constraint($res, $bound)Returns $res if value < $bound
Less than or equal to boundmake_le_constraint($res, $bound)Returns $res if value <= $bound
Greater than boundmake_gt_constraint($res, $bound)Returns $res if value > $bound
Greater than or equal to boundmake_ge_constraint($res, $bound)Returns $res if value >= $bound
Maximum length validationmake_length_constraint($max_length)Returns true if value length <= $max_length

📖 DESCRIPTION

This module contains functions to help generate complex constraints.

If you are writing new code, take a look at Data::FormValidator::Constraints::MethodsFactory instead. It's a modern alternative to what's here, offering improved names and syntax.

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

đŸ”ĸ BOOLEAN CONSTRAINTS

Those constraints are available by using the :bool tag.

🔹 make_not_constraint( $c1 )

This will create a constraint that will return the negation of the result of constraint $c1.

🔹 make_or_constraint( @constraints )

This will create a constraint that will return the result of the first constraint that returns a non false result.

🔹 make_and_constraint( @constraints )

This will create a constraint that will return the result of the first constraint that returns a non false result only if all constraints return a non-false result.

🧩 SET CONSTRAINTS

Those constraints are available by using the :set tag.

🔹 make_set_constraint( $res, @elements )

This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise.

The eq operator is used for comparison.

🔹 make_num_set_constraint( $res, @elements )

This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise.

The == operator is used for comparison.

🔹 make_word_set_constraint( $res, $set )

This will create a constraint that will return $res if the value is a word in $set, or the negation of $res otherwise.

🔹 make_cmp_set_constraint( $res, $cmp, @elements )

This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise.

$cmp is a function which takes two arguments and should return true or false depending if the two elements are equal.

đŸ”ĸ NUMERICAL LOGICAL CONSTRAINTS

Those constraints are available by using the :num tag.

🔹 make_clamp_constraint( $res, $low, $high )

This will create a constraint that will return $res if the value is between $low and $high bounds included, or its negation otherwise.

🔹 make_lt_constraint( $res, $bound )

This will create a constraint that will return $res if the value is lower than $bound, or the negation of $res otherwise.

🔹 make_le_constraint( $res, $bound )

This will create a constraint that will return $res if the value is lower or equal than $bound, or the negation of $res otherwise.

🔹 make_gt_constraint( $res, $bound )

This will create a constraint that will return $res if the value is greater than $bound, or the negation of $res otherwise.

🔹 make_ge_constraint( $res, $bound )

This will create a constraint that will return $res if the value is greater or equal than $bound, or the negation of $res otherwise.

🧰 OTHER CONSTRAINTS

🔹 make_length_constraint($max_length)

This will create a constraint that will return true if the value has a length of less than or equal to $max_length.

📚 SEE ALSO

Data::FormValidator(3)

👤 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.

perl v5.26.1 2017-10-24 Data::FormValidator::ConstraintsFactory(3pm)

Data::FormValidator::ConstraintsFactory
Data::FormValidator::ConstraintsFactory(3pm) 📛 NAME 🚀 Quick Reference 📖 DESCRIPTION 📝 SYNOPSIS đŸ”ĸ BOOLEAN CONSTRAINTS
🔹 make_not_constraint( $c1 ) 🔹 make_or_constraint( @constraints ) 🔹 make_and_constraint( @constraints )
🧩 SET CONSTRAINTS
🔹 make_set_constraint( $res, @elements ) 🔹 make_num_set_constraint( $res, @elements ) 🔹 make_word_set_constraint( $res, $set ) 🔹 make_cmp_set_constraint( $res, $cmp, @elements )
đŸ”ĸ NUMERICAL LOGICAL CONSTRAINTS
🔹 make_clamp_constraint( $res, $low, $high ) 🔹 make_lt_constraint( $res, $bound ) 🔹 make_le_constraint( $res, $bound ) 🔹 make_gt_constraint( $res, $bound ) 🔹 make_ge_constraint( $res, $bound )
🧰 OTHER CONSTRAINTS
🔹 make_length_constraint($max_length)
📚 SEE ALSO 👤 AUTHOR ÂŠī¸ COPYRIGHT

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-07 04:54 @2600:1f28:365:80b0:ed19:4cb6:6073:b302
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^