Handel::Constraints(3)

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

Arguments: $quantity

Returns 1 if the value passed is a numeric, non-negative value that is less than or equal HandelMaxQuantity. Otherwise it returns "undef".

See Handel::ConfigReader for more information on HandelMaxQuantity and HandelMaxQuantityAction.

  constraint_price

Arguments: $price

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

  constraint_uuid

Arguments: $string

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

Arguments: $type

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

  constraint_currency_code

Arguments: $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

Arguments: $phase

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

  constraint_order_type

Arguments: $type

Returns 1 if the value passed is "ORDER_TYPE_SAVED" or "ORDER_TYPE_TEMP", otherwise it returns "undef".

  constraint_cart_name

Arguments: $name

Returns 0 if the cart type is "CART_TYPE_SAVED" and the name is undefined, otherwise it returns 1.

EXPORT_TAGS

  :all
Exports all functions into the callers namespace.

    use Handel::Constraints qw/:all/;

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