PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

LessThan

Zend_Validate_LessThan allows you to validate if a given value is less than a maximum border value. It is the cousine of Zend_Validate_GreaterThan.

Zend_Validate_LessThan supports only number validation

It should be noted that Zend_Validate_LessThan supports only the validation of numbers. Strings or dates can not be validated with this validator.

Supported options for Zend_Validate_LessThan

The following options are supported for Zend_Validate_LessThan:

  • max: Sets the maximum allowed value.

Basic usage

To validate if a given value is less than a defined border simply use the following example.

<?php
$valid  
= new Zend_Validate_LessThan(array('max' => 10));
$value  10;
$return $valid->isValid($value);
// returns true

The above example returns TRUE for all values which are equal to 10 or lower than 10.

Zend Framework