fValidationclassv1.0.0b5

Provides validation routines for standalone forms, such as contact forms

Changes:
1.0.0b5Added the $return_messages parameter to validate() and updated code for new fValidationException API 9/17/09
1.0.0b4Changed date checking from strtotime() to fTimestamp for better localization support 6/1/09
1.0.0b3Updated for new fCore API 2/16/09
1.0.0b2Added support for validating date and URL fields 1/23/09
1.0.0bThe initial implementation 6/14/07

Static Methods

::compose() protected

Composes text using fText if loaded

Signature

string compose( string $message, mixed $component )

Parameters

string $message The message to compose
mixed $component [, ... ] A string or number to insert into the message

Returns

The composed and possible translated message

::stringlike() protected

Returns TRUE for non-empty strings, numbers, objects, empty numbers and string-like numbers (such as 0, 0.0, '0')

Signature

boolean stringlike( mixed $value )

Parameters

mixed $value The value to check

Returns

If the value is string-like

Methods

->__get() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

All requests that hit this method should be requests for callbacks

Signature

callback __get( string $method )

Parameters

string $method The method to create a callback for

Returns

The callback for the method requested

->addDateFields() public

Adds form fields to the list of fields to be blank or a valid date

Use addRequiredFields() disallow blank values.

Signature

void addDateFields( string $field )

Parameters

string $field [, ... ] Any number of fields that should contain a valid date

->addEmailFields() public

Adds form fields to the list of fields to be blank or a valid email address

Use addRequiredFields() disallow blank values.

Signature

void addEmailFields( string $field )

Parameters

string $field [, ... ] Any number of fields that should contain a valid email address

->addEmailHeaderFields() public

Adds form fields to be checked for email injection

Every field that is included in email headers should be passed to this method.

Signature

void addEmailHeaderFields( string $field )

Parameters

string $field [, ... ] Any number of fields to be checked for email injection

->addRequiredFields() public

Adds form fields to be required, taking each parameter as a field name

To require one of multiple fields, pass an array of fields as the parameter.

To conditionally require fields, pass an associative array of with the key being the field that will trigger the other fields to be required:

array(
    'trigger_field' => array(
        'conditionally_required_field',
        'second_conditionally_required_field'
    )
);

Signature

void addRequiredFields( mixed $field )

Parameters

mixed $field [, ... ] Any number of fields to check

->addURLFields() public

Adds form fields to the list of fields to be blank or a valid URL

Use addRequiredFields() disallow blank values.

Signature

void addURLFields( string $field )

Parameters

string $field [, ... ] Any number of fields that should contain a valid URL

->validate() public

Checks for required fields, email field formatting and email header injection using values previously set

Signature

void|array validate( boolean $return_messages=FALSE )

Parameters

boolean $return_messages If an array of validation messages should be returned instead of an exception being thrown

Returns

If $return_messages is TRUE, an array of validation messages will be returned

Throws

fValidationException
When one of the options set for the object is violated