Docs For Class FormValidation

## Class FormValidation

Description

This is the base validation class that contains some basic FormElement validation methods.

Located in /form/FormValidation.inc (line 33)

Variable Summary
mixed $_error_code
mixed $_error_message
mixed $_FormErrors
Method Summary
FormValidation FormValidation (FormErrors &$error_obj)
void array_hasempty (mixed $a)
string get_error_code ()
string get_error_message ()
boolean is_alphanum (string $str, [string $from = ""])
TRUE is_alphanumstring (string $str)
TRUE is_ccexp (string $value, [mixed $split_by = "-"])
TRUE is_companyname (string $name)
TRUE is_confirm_password (string $confirmpassword, mixed $password)
TRUE is_countrycode (string $value)
TRUE is_date (string $value, [mixed $split_by = "-"])
TRUE is_dateday (string $day)
TRUE is_datemonth (string $month)
TRUE is_datetime (string $value)
TRUE is_dateyear (string $year)
TRUE is_domainname (string $name, [mixed $forbid_www = FALSE])
TRUE is_email (string $email, [bool $allow_name = true])
TRUE is_firstname (string $firstname)
TRUE is_float (string $number)
TRUE is_higherzeronumber (string $value)
void is_host (mixed $host)
TRUE is_hostemail (string $name)
TRUE is_hostip (string $hostip)
void is_hostlist (mixed $hostlist)
TRUE is_hostname (string $name)
TRUE is_ip (string $ip)
TRUE is_lastname (string $lastname)
TRUE is_leapyear (string $yyyy)
TRUE is_manyemails (string $emails)
TRUE is_money (string $money)
TRUE is_name (string $name, [int $maxsize = VALIDATE_MAXSIZE])
TRUE is_notempty (mixed $value)
boolean is_num (string $str, [string $from = ""])
TRUE is_number (string $value)
TRUE is_partial_domainname (string $name)
TRUE is_partial_ip (string $ip)
TRUE is_password (string $password)
TRUE is_path (string $path)
TRUE is_price (string $price)
void is_range (mixed $value, mixed $size, mixed $min, mixed $max)
TRUE is_regex (string $regex, string $str)
TRUE is_standalone_hostname (string $name)
TRUE is_strict_url (string $url)
TRUE is_time (string $value)
TRUE is_title (string $name)
TRUE is_url (string $url)
TRUE is_urlpath (string $path)
TRUE is_username (string $username)
TRUE is_valid_domain (string $domain_value, [mixed $allow_www = false])
TRUE is_within_range (mixed $value, int $size, mixed $start, mixed $end, [string $error = FALSE])
TRUE is_zero_onehundred (string $value)
TRUE is_zip (string $zip)
FormValidation &singleton ()
FALSE _error (string $code, [mixed $message = NULL])
Variables
mixed $_error_code = '' (line 38)

This holds the last error code found

mixed $_error_message = '' (line 43)

This holds the last error message

mixed $_FormErrors = NULL (line 48)

This is the FormErrors object

Methods
Constructor FormValidation (line 58)

The constructor used to set the form errors object used by this class to do error text lookups

FormValidation FormValidation (FormErrors &$error_obj)

- FormErrors &$error_obj: object

array_hasempty (line 87)

This method checks to make sure an array doesn't have an empty element.

void array_hasempty (mixed $a)
get_error_code (line 127)

This method returns the error code from the last validation error found.

string get_error_code ()
get_error_message (line 138)

This method returns the error message from the last validation error found.

string get_error_message ()
is_alphanum (line 170)

This function checks if the given string contains alphabetical characters or numbers.

It also checks for the allowed additional characters.

- return: FALSE - if any other extraneous characters are found TRUE upon succes.

boolean is_alphanum (string $str, [string $from = ""])

- string $str: - the string to check
- string $from: - list of individual characters to allow besides a-zA-Z

is_alphanumstring (line 288)

This method validates a string as containing only letters and numbers

- return: = succes FALSE = failed

TRUE is_alphanumstring (string $str)

- string $str: - the value to validate

is_ccexp (line 1045)

This tests a string as a valid credit card expiration date.

You can pass in an optional date delimiter string. The default is -

- return: = succes FALSE = failed

TRUE is_ccexp (string $value, [mixed $split_by = "-"])

- string $value: - the value to validate

is_companyname (line 659)

This validates a string as a valid Company name.

It is the same as is_name, with the exception of allowing .

- return: = succes FALSE = failed

TRUE is_companyname (string $name)

- string $name: - the value to validate

is_confirm_password (line 715)

This makes sure that 2 password strings are exactly alike.

- return: = succes FALSE = failed

TRUE is_confirm_password (string $confirmpassword, mixed $password)

- string $confirmpassword: - the value to validate

is_countrycode (line 1076)

This validates a string as a valid "country code" which is a 2 alphanumerical character string

- return: = succes FALSE = failed

TRUE is_countrycode (string $value)

- string $value: - the value to validate

is_date (line 861)

This validates a atring as a valid date format You can provide a seperator string that seperates the fields

NOTE: date is in YYYY-MO-DY format

- return: = succes FALSE = failed

TRUE is_date (string $value, [mixed $split_by = "-"])

- string $value: - the value to validate

is_dateday (line 900)

This validates a string as a valid day of a month It has to be greater then 0 and less then 31

- return: = succes FALSE = failed

TRUE is_dateday (string $day)

- string $day: - the value to validate

is_datemonth (line 913)

This validates a string as a valid month of the year between 1 and 12 inclusive is_datemonth - checks whether its a proper month

- return: = succes FALSE = failed

TRUE is_datemonth (string $month)

- string $month: - the value to validate

is_datetime (line 946)

This validates an array of values as a valid date time

NOTE: array must contain array( "month" => VALUE, "day" => VALUE, "year" => VALUE, "hour" => VALUE, "minutes" => VALUE, "seconds" => VALUE);

- return: = succes FALSE = failed

TRUE is_datetime (string $value)

- string $value: - the value to validate

is_dateyear (line 925)

See if the year is within 1800 and 3000

- return: = succes FALSE = failed

TRUE is_dateyear (string $year)

- string $year: - the value to validate

is_domainname (line 335)

This method validates a string for a valid hostname for a machine.

- return: = succes FALSE = failed

TRUE is_domainname (string $name, [mixed $forbid_www = FALSE])

- string $name: - the value to validate

is_email (line 749)

This function validates a single email address.

It supports email addresses in the format of jane@blah.com or "Jane Doe <jane@blah.com>"

- return: = succes FALSE = failed

TRUE is_email (string $email, [bool $allow_name = true])

- string $email: - the value to validate
- bool $allow_name: - allows long email name format

is_firstname (line 1005)

This is just a wrapper for

- return: = succes FALSE = failed

TRUE is_firstname (string $firstname)

- string $firstname: - the value to validate

is_float (line 537)

This method validates a string as a valid float formatted number. x.xx

- return: = succes FALSE = failed

TRUE is_float (string $number)

- string $number: - the value to validate

is_higherzeronumber (line 585)

This method validates a string as a number greater then 0.

- return: = succes FALSE = failed

TRUE is_higherzeronumber (string $value)

- string $value: - the value to validate

is_host (line 1186)

no comment

void is_host (mixed $host)
is_hostemail (line 731)

This method tests a string as a valid hostname value or a valid email string

- return: = succes FALSE = failed

TRUE is_hostemail (string $name)

- string $name: - the value to validate

is_hostip (line 455)

This method tries to validate a string as a valid IP address or a hostname

- return: = succes FALSE = failed

TRUE is_hostip (string $hostip)

- string $hostip: - the value to validate

is_hostlist (line 1194)

no comment

void is_hostlist (mixed $hostlist)
is_hostname (line 379)

This is just a wrapper for is_domainname

- return: = succes FALSE = failed

TRUE is_hostname (string $name)

- string $name: - the value to validate

is_ip (line 391)

This validates a string as an IP address This should work with either IPv4 or IPv6

- return: = succes FALSE = failed

TRUE is_ip (string $ip)

- string $ip: - the value to validate

is_lastname (line 1016)

This is just a wrapper for

- return: = succes FALSE = failed

TRUE is_lastname (string $lastname)

- string $lastname: - the value to validate

is_leapyear (line 843)

This method validates a string as a leap year.

- return: = succes FALSE = failed

TRUE is_leapyear (string $yyyy)

- string $yyyy: - the value to validate

is_manyemails (line 822)

This function tests a string that may contain many email addresses seperated by commas

- return: = succes FALSE = failed

TRUE is_manyemails (string $emails)

- string $emails: - the value to validate

is_money (line 489)

This method tests a string to make sure it is in a valid money format.

either $x or $x.cents

- return: = succes FALSE = failed

TRUE is_money (string $money)

- string $money: - the value to validate

is_name (line 637)

This validates a string as a valid proper name.

The string can't be longer then VALIDATE_MAXSIZE in length, and it can only contain letters and numbers

- return: = succes FALSE = failed

TRUE is_name (string $name, [int $maxsize = VALIDATE_MAXSIZE])

- string $name: - the value to validate
- int $maxsize: - the maximum allowable length DEFAULT : VALIDATE_MAXSIZE

is_notempty (line 150)

This function makes sure the data is not empty

- return: = not empty

TRUE is_notempty (mixed $value)

- mixed $value

is_num (line 204)

This function checks if the given string contains numerical digit characters.

It also checks for the allowed additional characters.

- return: FALSE - if any other extraneous characters are found TRUE upon succes.

boolean is_num (string $str, [string $from = ""])

- string $str: - the string to check
- string $from: - list of individual characters to allow besides a-zA-Z

is_number (line 473)

This tests a string to make sure it is a valid number.

- return: = succes FALSE = failed

TRUE is_number (string $value)

- string $value: - the value to validate

is_partial_domainname (line 353)

This method validates a string for a valid partial hostname for a machine.

- return: = succes FALSE = failed

TRUE is_partial_domainname (string $name)

- string $name: - the value to validate

is_partial_ip (line 426)

This validates a string as a portion of an IP address.

This should work with either IPv4 or IPv6

- return: = succes FALSE = failed

TRUE is_partial_ip (string $ip)

- string $ip: - the value to validate

is_password (line 700)

This tries to validate a string as a password It can't be empty and has to be less then VALIDATE_MAXSIZE characters in length

NOTE: password is case sensitive, and spaces are ignored.

- return: = succes FALSE = failed

TRUE is_password (string $password)

- string $password: - the value to validate

is_path (line 602)

This method validates a string as a path to a file.

- return: = succes FALSE = failed

TRUE is_path (string $path)

- string $path: - the value to validate

is_price (line 515)

This method tries to validate a string as a valid price. It can't be zero (a la free!)

- return: = succes FALSE = failed

TRUE is_price (string $price)

- string $price: - the value to validate

is_range (line 241)

is_range

This is the range check that the can be used in checks_array. Valarray should be: array('val' => $val, 'size' => $size OPTIONAL 'min' => $min, 'max' => $max, )

void is_range (mixed $value, mixed $size, mixed $min, mixed $max)
is_regex (line 1211)

Validate if the string matches a regex

- return: = succes FALSE = failed

TRUE is_regex (string $regex, string $str)

- string $regex: - the regex string
- string $str: - the value to validate

is_standalone_hostname (line 303)

this method tests to see if this is a valid hostname value minus the domain name portion.

- return: = succes FALSE = failed

TRUE is_standalone_hostname (string $name)

- string $name: - the value to validate

is_strict_url (line 1133)

This method validates a strict url.

It is the same as is_url, except that it requires the prefix http://

- return: = succes FALSE = failed

TRUE is_strict_url (string $url)

- string $url: - the value to validate

is_time (line 978)

This validates an array of fields as a valid time of the day

NOTE: array must contain array( "hour" => VALUE, "minutes" => VALUE, "seconds" => VALUE);

- return: = succes FALSE = failed

TRUE is_time (string $value)

- string $value: - the value to validate

is_title (line 1151)

Validate if the string is a good candidate to become an Title

- return: = succes FALSE = failed

TRUE is_title (string $name)

- string $name: - the value to validate

is_url (line 1094)

This method validates a string as a valid url It inclues the prefix, hostname/ip, port number and path.

NOTE: format is in [http://] hostip [:port number] [path]

- return: = succes FALSE = failed

TRUE is_url (string $url)

- string $url: - the value to validate

is_urlpath (line 618)

This method validates a string as a valid url path to a file

- return: = succes FALSE = failed

TRUE is_urlpath (string $path)

- string $path: - the value to validate

is_username (line 674)

This method tests to see if a string value

is a valid 'account' name. The string can't be larger then VALIDATE_MAXSIZE, and can only contain alphanum characters

- return: = succes FALSE = failed

TRUE is_username (string $username)

- string $username: - the value to validate

is_valid_domain (line 1166)

Validate domain Will check if a domain is valid

- return: = succes FALSE = failed

TRUE is_valid_domain (string $domain_value, [mixed $allow_www = false])

- string $domain_value: - the value to validate

is_within_range (line 260)

This method makes sure a value lies within a given range of values.

The error message can be customized by passing in a customer error code

- return: = succes FALSE = failed

TRUE is_within_range (mixed $value, int $size, mixed $start, mixed $end, [string $error = FALSE])

- mixed $value: - the value u want to check
- int $size: - the size
- mixed $start: - the lower bound value
- mixed $end: - the upper bound value
- string $error: - the error code if any

is_zero_onehundred (line 564)

This validates a string as a valid number between 0 and 100

- return: = succes FALSE = failed

TRUE is_zero_onehundred (string $value)

- string $value: - the value to validate

is_zip (line 1029)

This validates a string as a valid zipcode

numbers, whitespace allowed

- return: = succes FALSE = failed

TRUE is_zip (string $zip)

- string $zip: - the value to validate

singleton (line 70)

A singleton method for only creating one instance of this per request.

- return: object

FormValidation &singleton ()
_error (line 108)

A wrapper method to set the error message and error code before returning FALSE

FALSE _error (string $code, [mixed $message = NULL])

- string $code: - error code

Documentation generated on Thu, 1 Sep 2005 17:06:01 -0700 by phpDocumentor 1.3.0RC3