Class Validation
Rules used for validation of form fields.
Methods summary
public
|
#
Validation( string $func_name )
Initialise a new validation.
Initialise a new validation.
Parameters
- $func_name
string $func_name The javascript function name to call onsubmit of the form
|
public
|
#
AddRule( string $fieldname, string $error_message, string $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
Adds a validation rule for a specific field upon submission of the form. You
must call RenderRules below RenderFields when outputing the page
Parameters
- $fieldname
string $fieldname The name of the field.
- $error_message
string $error_message The message to display on unsuccessful validation.
- $function_name
string $function_name The function to call to validate the field
|
public
string
|
#
RenderJavascript( string $prefix = "" )
Returns the javascript for form validation using the rules.
Returns the javascript for form validation using the rules.
Parameters
- $prefix
string $onsubmit The name of the function called on submission of the form.
Returns
string HTML/Javascript for form validation.
|
public
boolean
|
#
Validate( object $object )
Validates the form according to it's rules.
Validates the form according to it's rules.
Parameters
- $object
object $object The data object that requires form validation.
Returns
boolean True if the validation succeeded.
|
public
boolean
|
#
not_empty( string $field_string )
Checks if a string is empty
Checks if a string is empty
Parameters
- $field_string
string $field_string The field value that is being checked.
Returns
boolean True if the string is not empty.
|
public
boolean
|
#
selected( string $field_string )
Checks that a string is not empty or zero
Checks that a string is not empty or zero
Parameters
- $field_string
string $select_string The select value that is being checked.
Returns
boolean True if the string is not empty or equal to 0.
|
public
boolean
|
#
positive_dollars( string $field_string )
Check that the given string is a positive dollar amount. Use not_empty first
if string is required.
Check that the given string is a positive dollar amount. Use not_empty first
if string is required.
Parameters
- $field_string
string $field_string The amount to be checked.
Returns
boolean Returns true if the given string is a positive dollar amount.
|
public
boolean
|
#
positive_integer( string $field_string )
Check that the given string is a positive integer. Use not_empty first if
string is required.
Check that the given string is a positive integer. Use not_empty first if
string is required.
Parameters
- $field_string
string $field_string The amount to be checked.
Returns
boolean Returns true if the given string is a positive integer.
|
public
boolean
|
#
valid_email_format( string $field_string )
Check that the given string is a valid email address. Use not_empty first if
string is required.
Check that the given string is a valid email address. Use not_empty first if
string is required.
Parameters
- $field_string
string $field_string The string to be checked.
Returns
boolean Returns true if the given string is a valid email address.
|
public
boolean
|
#
valid_date_format( string $field_string )
Check that the given string matches the user's date format. Use not_empty
first if string is required.
Check that the given string matches the user's date format. Use not_empty
first if string is required.
Parameters
- $field_string
string $field_string The string to be checked.
Returns
boolean Returns true if the given string matches the user's date format from session.
|