Validation Class Reference

Inheritance diagram for Validation:

Object

List of all members.


Public Member Functions

 _check ()
 _extract ($params)
 _luhn ()
 alphaNumeric ($check)
 between ($check, $min, $max)
 blank ($check)
 cc ($check, $type= 'fast', $deep=false, $regex=null)
 comparison ($check1, $operator=null, $check2=null)
 custom ($check, $regex=null)
 date ($check, $format= 'ymd', $regex=null)
 decimal ($check, $places=null, $regex=null)
 email ($check, $deep=false, $regex=null)
 equalTo ($check, $comparedTo)
 extension ($check, $extensions=array('gif', 'jpeg', 'png', 'jpg'))
 file ($check)
 ip ($check)
 maxLength ($check, $max)
 minLength ($check, $min)
 money ($check, $symbolPosition= 'left')
 multiple ($check, $type, $regex=null)
 numeric ($check)
 phone ($check, $regex=null, $country= 'all')
 postal ($check, $regex=null, $country=null)
 range ($check, $lower=null, $upper=null)
 ssn ($check, $regex=null, $country=null)
 url ($check)
 userDefined ($check, $object, $method, $args=null)

Static Public Member Functions

getInstance ()

Public Attributes

 $check = null
 $country = null
 $deep = null
 $errors = array()
 $regex = null
 $type = null

Detailed Description

Definition at line 57 of file validation.php.


Member Function Documentation

Validation::_check (  ) 

Runs a regular expression match.

Returns:
boolean Success of match protected

Definition at line 772 of file validation.php.

References getInstance().

Referenced by alphaNumeric(), blank(), cc(), and date().

Validation::_extract ( params  ) 

Get the values to use when value sent to validation method is an array.

Parameters:
array $params Parameters sent to validation method protected

Definition at line 789 of file validation.php.

References getInstance().

Validation::_luhn (  ) 

Luhn algorithm

See also:
http://en.wikipedia.org/wiki/Luhn_algorithm
Returns:
boolean Success protected

Definition at line 816 of file validation.php.

References getInstance().

Validation::alphaNumeric ( check  ) 

Checks that a string contains only integer or letters

Returns true if string contains only integer or letters

$check can be passed as an array: array('check' => 'valueToCheck');

Parameters:
mixed $check Value to check
Returns:
boolean Success public

Definition at line 130 of file validation.php.

References $check, _check(), and getInstance().

Validation::between ( check,
min,
max 
)

Checks that a string length is within s specified range. Spaces are included in the character count. Returns true is string matches value min, max, or between min and max,

Parameters:
string $check Value to check for length
integer $min Minimum value in range (inclusive)
integer $max Maximum value in range (inclusive)
Returns:
boolean Success public

Definition at line 161 of file validation.php.

References $check.

Validation::blank ( check  ) 

Returns true if field is left blank -OR- only whitespace characters are present in it's value Whitespace characters include Space, Tab, Carriage Return, Newline

$check can be passed as an array: array('check' => 'valueToCheck');

Parameters:
mixed $check Value to check
Returns:
boolean Success public

Definition at line 181 of file validation.php.

References $check, _check(), and getInstance().

Validation::cc ( check,
type = 'fast',
deep = false,
regex = null 
)

Validation of credit card numbers. Returns true if $check is in the proper credit card format.

Parameters:
mixed $check credit card number to validate
mixed $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit cards if an array is used only the values of the array are checked. Example: array('amex', 'bankcard', 'maestro')
boolean $deep set to true this will check the Luhn algorithm of the credit card.
string $regex A custom regex can also be passed, this will be used instead of the defined regex values
Returns:
boolean Success public
See also:
Validation::_luhn()

Definition at line 211 of file validation.php.

References $check, $deep, $regex, $type, _check(), and getInstance().

Validation::comparison ( check1,
operator = null,
check2 = null 
)

Used to compare 2 numeric values.

Parameters:
mixed $check1 if string is passed for a string must also be passed for $check2 used as an array it must be passed as array('check1' => value, 'operator' => 'value', 'check2' -> value)
string $operator Can be either a word or operand is greater >, is less <, greater or equal >= less or equal <=, is less <, equal to ==, not equal !=
integer $check2 only needed if $check1 is a string
Returns:
bool public

Definition at line 287 of file validation.php.

References getInstance().

Validation::custom ( check,
regex = null 
)

Used when a custom regular expression is needed.

Parameters:
mixed $check When used as a string, $regex must also be a valid regular expression. As and array: array('check' => value, 'regex' => 'valid regular expression')
string $regex If $check is passed as a string, $regex must also be set to valid regular expression
Returns:
boolean Success public

Definition at line 348 of file validation.php.

References $check, $regex, a(), and getInstance().

Validation::date ( check,
format = 'ymd',
regex = null 
)

Date validation, determines if the string passed is a valid date. keys that expect full month, day and year will validate leap years

Parameters:
string $check a valid date string
mixed $format Use a string or an array of the keys below. Arrays should be passed as array('dmy', 'mdy', etc) Keys: dmy 27-12-2006 or 27-12-06 separators can be a space, period, dash, forward slash mdy 12-27-2006 or 12-27-06 separators can be a space, period, dash, forward slash ymd 2006-12-27 or 06-12-27 separators can be a space, period, dash, forward slash dMy 27 December 2006 or 27 Dec 2006 Mdy December 27, 2006 or Dec 27, 2006 comma is optional My December 2006 or Dec 2006 my 12/2006 or 12/06 separators can be a space, period, dash, forward slash
string $regex If a custom regular expression is used this is the only validation that will occur.
Returns:
boolean Success public

Definition at line 379 of file validation.php.

References $check, $regex, _check(), getInstance(), and r().

Validation::decimal ( check,
places = null,
regex = null 
)

Checks that a value is a valid decimal. If $places is null, the $check is allowed to be a scientific float If no decimal point is found a false will be returned. Both the sign and exponent are optional.

Parameters:
integer $check The value the test for decimal
integer $places if set $check value must have exactly $places after the decimal point
string $regex If a custom regular expression is used this is the only validation that will occur.
Returns:
boolean Success public

Definition at line 425 of file validation.php.

References $check, $regex, and getInstance().

Validation::email ( check,
deep = false,
regex = null 
)

Validates for an email address.

Parameters:
string $check Value to check
boolean $deep Perform a deeper validation (if true), by also checking availability of host
string $regex Regex to use (if none it will use built in regex)
Returns:
boolean Success public

Definition at line 452 of file validation.php.

References a(), and getInstance().

Validation::equalTo ( check,
comparedTo 
)

Check that value is exactly $comparedTo.

Parameters:
mixed $check Value to check
mixed $comparedTo Value to compare public

Definition at line 487 of file validation.php.

Validation::extension ( check,
extensions = array('gif', 'jpeg', 'png', 'jpg') 
)

Check that value has a valid file extenstion.

Parameters:
mixed $check Value to check
array $extensions file extenstions to allow public

Definition at line 497 of file validation.php.

Validation::file ( check  ) 

Check that value is a file type.

Parameters:
mixed $check Value to check public
Todo:
Implement

Definition at line 520 of file validation.php.

& Validation::getInstance (  )  [static]

Gets a reference to the Validation object instance

Returns:
object Validation instance public

Definition at line 110 of file validation.php.

Referenced by _check(), _extract(), _luhn(), alphaNumeric(), blank(), cc(), comparison(), custom(), date(), decimal(), email(), Model::invalidFields(), money(), phone(), postal(), ssn(), and url().

Validation::ip ( check  ) 

Validation of an IPv4 address.

Parameters:
string $check The string to test.
Returns:
boolean Success public

Definition at line 530 of file validation.php.

Referenced by CakeSocket::address(), CakeSocket::addresses(), and CakeSocket::host().

Validation::maxLength ( check,
max 
)

Checks whether the length of a string is smaller or equal to a maximal length..

Parameters:
string $check The string to test
integer $max The maximal string length
Returns:
boolean Success public

Definition at line 563 of file validation.php.

Validation::minLength ( check,
min 
)

Checks whether the length of a string is greater or equal to a minimal length.

Parameters:
string $check The string to test
integer $min The minimal string length
Returns:
boolean Success public

Definition at line 551 of file validation.php.

Validation::money ( check,
symbolPosition = 'left' 
)

Checks that a value is a monetary amount.

Parameters:
string $check Value to check
string $symbolPosition Where symbol is located (left/right)
Returns:
boolean Success public

Definition at line 575 of file validation.php.

References getInstance().

Validation::multiple ( check,
type,
regex = null 
)

Validate a multiple select.

Parameters:
mixed $check Value to check
mixed $type Type of check
string $regex Use custom regular expression public
Todo:
Implement

Definition at line 597 of file validation.php.

Validation::numeric ( check  ) 

Checks if a value is numeric.

Parameters:
string $check Value to check
Returns:
boolean Succcess public

Definition at line 609 of file validation.php.

Validation::phone ( check,
regex = null,
country = 'all' 
)

Check that a value is a valid phone number.

Parameters:
mixed $check Value to check (string or array)
string $regex Regular expression to use
string $country Country code (defaults to 'all')
Returns:
boolean Success public

Definition at line 621 of file validation.php.

References getInstance().

Validation::postal ( check,
regex = null,
country = null 
)

Checks that a given value is a valid postal code.

Parameters:
mixed $check Value to check
string $regex Regular expression to use
string $country Country to use for formatting
Returns:
boolean Success public

Definition at line 649 of file validation.php.

References getInstance().

Validation::range ( check,
lower = null,
upper = null 
)

Validate that a number is in specified range. if $lower and $upper are not set, will return true if $check is a legal finite on this platform

Parameters:
string $check Value to check
integer $lower Lower limit
integer $upper Upper limit public

Definition at line 688 of file validation.php.

Validation::ssn ( check,
regex = null,
country = null 
)

Checks that a value is a valid Social Security Number.

Parameters:
mixed $check Value to check
string $regex Regular expression to use
string $country Country
Returns:
boolean Success public

Definition at line 713 of file validation.php.

References getInstance().

Validation::url ( check  ) 

Checks that a value is a valid URL.

Parameters:
string $check Value to check
Returns:
boolean Success public

Definition at line 745 of file validation.php.

References a(), and getInstance().

Validation::userDefined ( check,
object,
method,
args = null 
)

Runs an user-defined validation.

Parameters:
mixed $check value that will be validated in user-defined methods.
object $object class that holds validation method
string $method class method name for validation to run
array $args arguments to send to method
Returns:
mixed user-defined class class method returns public

Definition at line 763 of file validation.php.


Member Data Documentation

Validation::$check = null

Definition at line 64 of file validation.php.

Referenced by alphaNumeric(), between(), blank(), cc(), custom(), date(), and decimal().

Validation::$country = null

Definition at line 80 of file validation.php.

Validation::$deep = null

Definition at line 87 of file validation.php.

Referenced by cc().

Validation::$errors = array()

Definition at line 102 of file validation.php.

Validation::$regex = null

Definition at line 72 of file validation.php.

Referenced by cc(), custom(), date(), and decimal().

Validation::$type = null

Definition at line 94 of file validation.php.

Referenced by cc().


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