8.3. Profile checking

Interchange can check forms for compliance with requirements. The mechanism uses a profile, which is set via the mv_form_profile or mv_order_profile variables.

8.3.1. mv_form_profile

The mv_form_profile checks happen before any other action. They are designed to prevent submission of a form if required parameters are not present.

You define the profiles either in scratch space or with files specified in the OrderProfile directive.

Specifications take the form of an order page variable (like name or address), followed by an equals sign and a check type. There are many provided check types, and custom ones can be defined in a user-specified file using the CodeDef configuration directive.

Standard check types:

required

mandatory

phone

phone_us

state

province

state_province

zip

ca_postcode

postcode

true

false

email

regex

            foo=regex ^bar
       foo=regex ^bar "You must have bar at the beginning of this"
       foo=regex !^bar "You may not have bar at the beginning!"

length

       foo=length 4-10

unique

       foo=unique userdb Sorry, that username is already taken

filter

       foo=filter entities Sorry, no HTML allowed
            foo=filter lower Sorry, no uppercase characters

Also, there are pragmas that can be used to change behavior:

&charge

&credit_card

        # Checks credit card number and destroys number after encryption
        # The charge operation can never work
    
        &credit_card=standard
        &charge=custom authorizenet
    
        # Checks credit card number and keeps number after encryption
        # The charge operation can now work
    
        &credit_card=standard keep
        &charge=custom authorizenet
        &credit_card=check_cc

&fail

        &fail=page4

&fatal

&final

&update

&return

        # Success :)
        &return 1
    
        # Failure :\
        &return 0

&set

&setcheck

&success

        &success=page5

&update

        &update=yes

As an added measure of control, the specification is evaluated for the special Interchange tags to provide conditional setting of order parameters. With the [perl] [/perl] capability, quite complex checks can be done. Also, the name of the page to be displayed on an error can be set in the mv_failpage variable.

Error messages are set by appending the desired error message to the line containing the check:

city=required Please fill in your city.

This sets the value of the error associated with name, and can be displayed with the error tag:

        [error name=city show_error=1]