validator for Positive Integer Value
1 2 3 4 56 7 8 9 1011 12 13 14 15 | /** * Validates if $data given is integer and greater than a number $min * @param type $data * @param type $min * @return type */ public function validatePositiveInteger($data, $min=0) { $validator = new Zend_Validate_Int(); $validatorPositive = new Zend_Validate_GreaterThan($min); if (($validator->isValid($data)) && ($validatorPositive->isValid($data))) { return TRUE; } else { return FALSE; } } |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
Validates if $data given is an integer and greater than a number $min
Useful when you want to check if a $_post or $_GET variable is a possitive integer and greater than a value ex. year
$data='1999';
$min='2000';
the
validatePositiveInteger($data, $min);
will return false
Snippet details
- Created:
-
lenasterg
- Edited:
-
lenasterg
- Revision Id:
- 226
- Edit Message:
- Initial Release
- ZF Version
- 1.10.7
- Tags:
- validator possitive integer values
- Comments:
- 0
- Views:
- 441
- Points:
- 0 (0 votes)