Class WFKeyValueValidators

Description

Built-in Key-Value Validators.

The WFKeyValueValidators class provides a bunch of commonly used validators.

  • see: WFObject::validateValueForKey(), WFObject::validateValueForKeyPath()
  • todo: Should we standardize the 4th parameter of all of these functions to take in an array of options? For instance ('required' => true, 'country' => 'US')O This will provide a more consistent interface and make the canned validators ready if we decide to be able to add validation via configuration

Located in /framework/util/WFKeyValueValidators.php (line 19)

WFObject
   |
   --WFKeyValueValidators
Method Summary
static boolean validateEmail (mixed &$value, boolean &$edited, array &$errors)
static boolean validatePhone (mixed &$value, boolean &$edited, array &$errors, string $country)
static boolean validatePostalCode (mixed &$value, boolean &$edited, array &$errors, string $country)
Methods
static method validateEmail (line 29)

Validate email addresses.

  • return: TRUE indicates a valid value, FALSE indicates an error.
  • access: public
static boolean validateEmail (mixed &$value, boolean &$edited, array &$errors)
  • mixed &$value: A reference to value to check. Passed by reference so that the implementation can normalize the data.
  • boolean &$edited: A reference to a boolean. This value will always be FALSE when the method is called. If the implementation edits the $value, set to TRUE.
  • array &$errors: An array of WFError objects describing the error. The array is empty by default; you can add new error entries.
static method validatePhone (line 56)

Validate a phone number.

Pretty flexible; allows any character(s) as separators. Just tries to be sure that there are the right number of digits in the right number of groups.

Doesn't allow extensions.

  • return: TRUE indicates a valid value, FALSE indicates an error.
  • access: public
static boolean validatePhone (mixed &$value, boolean &$edited, array &$errors, string $country)
  • mixed &$value: A reference to value to check. Passed by reference so that the implementation can normalize the data.
  • boolean &$edited: A reference to a boolean. This value will always be FALSE when the method is called. If the implementation edits the $value, set to TRUE.
  • array &$errors: An array of WFError objects describing the error. The array is empty by default; you can add new error entries.
  • string $country: The country code you want to use for validation. Example: "US". Presently only US codes are supported. All other countries will cause the value to be assumed valid.
static method validatePostalCode (line 87)

Validate a postal code.

  • return: TRUE indicates a valid value, FALSE indicates an error.
  • access: public
static boolean validatePostalCode (mixed &$value, boolean &$edited, array &$errors, string $country)
  • mixed &$value: A reference to value to check. Passed by reference so that the implementation can normalize the data.
  • boolean &$edited: A reference to a boolean. This value will always be FALSE when the method is called. If the implementation edits the $value, set to TRUE.
  • array &$errors: An array of WFError objects describing the error. The array is empty by default; you can add new error entries.
  • string $country: The country code you want to use for validation. Example: "US". Presently only US codes are supported. All other countries will cause the value to be assumed valid.

Inherited Methods

Inherited From WFObject

WFObject::__construct()
WFObject::exposedProperties()
WFObject::getClass()
WFObject::keyPathToTargetAndKey()
WFObject::setValueForKey()
WFObject::setValueForKeyPath()
WFObject::validateValueForKey()
WFObject::validateValueForKeyPath()
WFObject::valueForKey()
WFObject::valueForKeyPath()
WFObject::valueForUndefinedKey()
WFObject::__toString()

Documentation generated on Thu, 17 Apr 2008 13:51:54 -0400 by phpDocumentor 1.4.1