FormLib
[ class tree: FormLib ] [ index: FormLib ] [ all elements ]

Class: Validator

Source Location: /FormLib/Validator.php

Class Overview


The Validator class supports testing field values to make sure the user enters properly formatted data.


Author(s):

  • Randy

Version:

  • 0.2

Methods


Child classes:

CompareFieldsValidator
This validator can compare the values of 2 fields. The values can be compare using the standard comparison operators (<, <=, ==, !=, etc...)
DefaultValueValidator
Supplies a default field value if the user leaves the field empty.
RangeValidator
Tests a field value an ensures it falls in a min/max range of numbers.
RegexValidator
Validates a field using a regular expression.
RequiredValidator
A simple validator that requires the user to enter a value.

Class Details

[line 21]
The Validator class supports testing field values to make sure the user enters properly formatted data.

Version 0.2 revises the isValid() and errorMessage() functions to accept the field being tested instead of the value in the field. This allows access to other field properties, such as the label for error messages.




Tags:

abstract:  
author:  Randy
version:  0.2


[ Top ]


Class Methods


method errorMessage [line 37]

string errorMessage( Field $field)

Get an error message that can be shown to the user.



Tags:

return:  The error message.
access:  public
abstract:  


Overridden in child classes as:

CompareFieldsValidator::errorMessage()
DefaultValueValidator::errorMessage()
This validator never generates an error.
RangeValidator::errorMessage()
RegexValidator::errorMessage()
RequiredValidator::errorMessage()

Parameters:

Field   $field   The field object.

[ Top ]

method isValid [line 29]

boolean isValid( Field &$field)

Validates the value the user entered into a field.



Tags:

return:  true if data is valid, false if not.
access:  public
abstract:  


Overridden in child classes as:

CompareFieldsValidator::isValid()
DefaultValueValidator::isValid()
Checks the value the user entered and if empty/missing, sets the field with the default value supplied to the constructor.
RangeValidator::isValid()
RegexValidator::isValid()
EmailValidator::isValid()
RequiredValidator::isValid()

Parameters:

Field   &$field   A reference to the Field object.

[ Top ]


Documentation generated on Wed, 15 Nov 2006 08:48:09 -0600 by phpDocumentor 1.3.1