Andrew's Web Libraries (AWL)
 All Classes Namespaces Functions Variables Pages
Validation Class Reference

Public Member Functions

 __construct ($func_name)
 
 AddRule ($fieldname, $error_message, $function_name)
 
 RenderJavascript ($prefix="")
 
 Validate ($object)
 
 not_empty ($field_string)
 
 selected ($field_string)
 
 positive_dollars ($field_string)
 
 positive_integer ($field_string)
 
 valid_email_format ($field_string)
 
 valid_date_format ($field_string)
 

Public Attributes

 $rules = array()
 
 $func_name = ""
 

Detailed Description

Definition at line 17 of file Validation.php.

Constructor & Destructor Documentation

Validation::__construct (   $func_name)

#@- Initialise a new validation.

Parameters
string$func_nameThe javascript function name to call onsubmit of the form

Definition at line 40 of file Validation.php.

Member Function Documentation

Validation::AddRule (   $fieldname,
  $error_message,
  $function_name 
)

Adds a validation rule for a specific field upon submission of the form. You must call RenderRules below RenderFields when outputing the page

Parameters
string$fieldnameThe name of the field.
string$error_messageThe message to display on unsuccessful validation.
string$function_nameThe function to call to validate the field

Definition at line 53 of file Validation.php.

Validation::not_empty (   $field_string)

Checks if a string is empty

Parameters
string$field_stringThe field value that is being checked.
Returns
boolean True if the string is not empty.

Definition at line 129 of file Validation.php.

Validation::positive_dollars (   $field_string)

Check that the given string is a positive dollar amount. Use not_empty first if string is required.

Parameters
string$field_stringThe amount to be checked.
Returns
boolean Returns true if the given string is a positive dollar amount.

Definition at line 150 of file Validation.php.

Validation::positive_integer (   $field_string)

Check that the given string is a positive integer. Use not_empty first if string is required.

Parameters
string$field_stringThe amount to be checked.
Returns
boolean Returns true if the given string is a positive integer.

Definition at line 167 of file Validation.php.

Validation::RenderJavascript (   $prefix = "")

Returns the javascript for form validation using the rules.

Parameters
string$onsubmitThe name of the function called on submission of the form.
string$prefixOptional prefix for form fields.
Returns
string HTML/Javascript for form validation.

Definition at line 64 of file Validation.php.

Validation::selected (   $field_string)

Checks that a string is not empty or zero

Parameters
string$select_stringThe select value that is being checked.
Returns
boolean True if the string is not empty or equal to 0.

Definition at line 139 of file Validation.php.

Validation::valid_date_format (   $field_string)

Check that the given string matches the user's date format. Use not_empty first if string is required.

Parameters
string$field_stringThe string to be checked.
Returns
boolean Returns true if the given string matches the user's date format from session.

Definition at line 193 of file Validation.php.

Validation::valid_email_format (   $field_string)

Check that the given string is a valid email address. Use not_empty first if string is required.

Parameters
string$field_stringThe string to be checked.
Returns
boolean Returns true if the given string is a valid email address.

Definition at line 179 of file Validation.php.

Validation::Validate (   $object)

Validates the form according to it's rules.

Parameters
object$objectThe data object that requires form validation.
Returns
boolean True if the validation succeeded.

Definition at line 99 of file Validation.php.


The documentation for this class was generated from the following file: