NAME

Handel::Constraints - Common database constraints used to validate input data

SYNOPSIS

use Handel::Constraints qw(constraint_quantity);

my $qty = 'bogus-1';

if (constraint_quantity($qty) {
    print 'invalid quantity';
};

DESCRIPTION

Handel::Constraints contains a set of functions used to validate data submitted by users into Handel objects. By default, Handel::Constraints doesn't export anything. Use the export tags to export groups of functions, or specify the exact methods you are interested in using. See Exporter for more information on using export tags.

FUNCTIONS

constraint_quantity

Returns 1 if the value passed is a numeric, non-negative value, otherwise it returns undef.

constraint_price

Returns 1 if the value passed is a numeric, non-negative value between 0 and 99999.99, otherwise it returns undef.

constraint_uuid

Returns 1 if the value passed is conforms to the GUID/UUID format, otherwise it returns undef. Currently, this does not expect the brackets around the value.

constraint_uuid( '11111111-1111-1111-1111-111111111111' ); # 1

constraint_uuid('{11111111-1111-1111-1111-111111111111}'); # undef

This will probably change in the future, or some sort of stripping of the brackets may occur.

constraint_cart_type

Returns 1 if the value passed is CART_TYPE_SAVED or CART_TYPE_TEMP, otherwise it returns undef.

constraint_currency_code

Returns 1 if the value passed is considered a 3 letter currency code. If Locale::Currency is installed, it will verify the 3 letter code is actually a valid currency code.

If Locale::Currency is not installed, it simply checks that the code conforms to:

/^[A-Z]{3}$/

constraint_checkout_phase

Returns 1 if the value passed is one of the CHECKOUT_PHASE_* constants, otherwise it returns undef.

EXPORT_TAGS

:all

Exports all functions into the classes namespace.

use Handel::Constraints qw(:all);

AUTHOR

Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/