Validation Class. Used for validation of model data
Offers different validation methods.
_check( string $check , string $regex )
Runs a regular expression match.
$check $regex boolean_pass( string $method , mixed $check , string $classPrefix )
Attempts to pass unhandled Validation locales to a class starting with $classPrefix and ending with Validation. For example $classPrefix = 'nl', the class would be NlValidation.
$method $check $classPrefix mixed_populateIp( )
Lazily populate the IP address patterns used for validations
alphaNumeric( string|array $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');
$check booleanbetween( string $check , integer $min , integer $max )
Alias of Validator::lengthBetween() for backwards compatibility.
$check $min $max booleanblank( string|array $check )
Returns true if field is left blank -OR- only whitespace characters are present in its value Whitespace characters include Space, Tab, Carriage Return, Newline
$check can be passed as an array: array('check' => 'valueToCheck');
$check booleanboolean( string $check )
Boolean validation, determines if value passed is a boolean integer or true/false.
$check booleancc( string|array $check , string|array $type 'fast' , boolean $deep false , string $regex null )
Validation of credit card numbers. Returns true if $check is in the proper credit card format.
$check $type optional 'fast' $deep optional false $regex optional null booleanValidation::luhn()comparison( string|array $check1 , string $operator null , integer $check2 null )
Used to compare 2 numeric values.
$check1 $operator optional null $check2 optional null booleancustom( string|array $check , string $regex null )
Used when a custom regular expression is needed.
$check $regex optional null booleandate( string $check , string|array $format 'ymd' , string $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.
Years are valid from 1800 to 2999.
dmy 27-12-2006 or 27-12-06 separators can be a space, period, dash, forward slashmdy 12-27-2006 or 12-27-06 separators can be a space, period, dash, forward slashymd 2006-12-27 or 06-12-27 separators can be a space, period, dash, forward slashdMy 27 December 2006 or 27 Dec 2006Mdy December 27, 2006 or Dec 27, 2006 comma is optionalMy December 2006 or Dec 2006my 12/2006 or 12/06 separators can be a space, period, dash, forward slashym 2006/12 or 06/12 separators can be a space, period, dash, forward slashy 2006 just the year without any separators$check $format optional 'ymd' $regex optional null booleandatetime( string $check , string|array $dateFormat 'ymd' , string $regex null )
Validates a datetime value
All values matching the "date" core validation rule, and the "time" one will be valid
$check $dateFormat optional 'ymd' $regex optional null booleanValidation::date()Validation::time()decimal( float $check , integer $places null , string $regex null )
Checks that a value is a valid decimal. Both the sign and exponent are optional.
Valid Places:
$check $places optional null $regex optional null booleanemail( string $check , boolean $deep false , string $regex null )
Validates for an email address.
Only uses getmxrr() checking for deep validation if PHP 5.3.0+ is used, or any PHP version on a non-Windows distribution
$check $deep optional false $regex optional null booleanequalTo( mixed $check , mixed $comparedTo )
Check that value is exactly $comparedTo.
$check $comparedTo booleanextension( string|array $check , array $extensions array('gif', 'jpeg', 'png', 'jpg') ) Check that value has a valid file extension.
$check $extensions optional array('gif', 'jpeg', 'png', 'jpg') booleanfileSize( string|array $check , string $operator null , integer|string $size null )
Checks the filesize
$check $operator optional null Validation::comparison().$size optional null booleaninList( string $check , array $list , boolean $caseInsensitive false )
Checks if a value is in a given list. Comparison is case sensitive by default.
$check $list $caseInsensitive optional false booleanip( string $check , string $type 'both' )
Validation of an IP address.
$check $type optional 'both' booleanlengthBetween( string $check , integer $min , integer $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,
$check $min $max booleanluhn( string|array $check , boolean $deep false )
Luhn algorithm
$check $deep optional false booleanmaxLength( string $check , integer $max )
Checks whether the length of a string is smaller or equal to a maximal length..
$check $max booleanmimeType( string|array $check , array|string $mimeTypes array() )
Checks the mime type of a file.
$check $mimeTypes optional array() booleanCakeExceptionminLength( string $check , integer $min )
Checks whether the length of a string is greater or equal to a minimal length.
$check $min booleanmoney( string $check , string $symbolPosition 'left' )
Checks that a value is a monetary amount.
$check $symbolPosition optional 'left' booleanmultiple( array $check , array $options array() , boolean $caseInsensitive false )
Validate a multiple select. Comparison is case sensitive by default.
Valid Options
$check $options optional array() $caseInsensitive optional false booleannaturalNumber( string $check , boolean $allowZero false )
Checks if a value is a natural number.
$check $allowZero optional false booleannotBlank( string|array $check )
Checks that a string contains something other than whitespace
Returns true if string contains something other than whitespace
$check can be passed as an array: array('check' => 'valueToCheck');
$check booleannotEmpty( string|array $check )
Backwards compatibility wrapper for Validation::notBlank().
$check booleanValidation::notBlank()numeric( string $check )
Checks if a value is numeric.
$check booleanphone( string|array $check , string $regex null , string $country 'all' )
Check that a value is a valid phone number.
$check $regex optional null $country optional 'all' booleanpostal( string|array $check , string $regex null , string $country 'us' )
Checks that a given value is a valid postal code.
$check $regex optional null $country optional 'us' booleanrange( string $check , integer|float $lower null , integer|float $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
$check $lower optional null $upper optional null booleanssn( string|array $check , string $regex null , string $country null )
Checks that a value is a valid Social Security Number.
$check $regex optional null $country optional null booleantime( string $check )
Time validation, determines if the string passed is a valid time. Validates time as 24hr (HH:MM) or am/pm ([H]H:MM[a|p]m) Does not allow/validate seconds.
$check booleanuploadError( string|array $check )
Checking for upload errors
$check booleanurl( string $check , boolean $strict false )
Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
The regex checks for the following component parts:
$check $strict optional false booleanuserDefined( string|array $check , object $object , string $method , array $args null )
Runs an user-defined validation.
$check $object $method $args optional null mixeduuid( string $check )
Checks that a value is a valid UUID - http://tools.ietf.org/html/rfc4122
$check boolean
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-Validation.html