GreaterOrEqual validator in Zend Framework

It was realized a few minutes ago that there is no GreaterOrEqualThan validator or a parameter in the GreaterThan validator that changes its behavior from > to >= .

Why? Is it possible to compose a validator >= using the basic set of zend frames for validators?

Yes guys, I know that I can write my own validator, but I'm curious about a solution based on my own ZF validators; -)

+4
source share
1 answer

I set array('min' => ($value-1)) and would use GreaterThan . Perhaps use a chain and add Digits to make sure you are dealing with numbers. Something like that:

 $value = 10; $chain = new Zend_Validate(); $chain->addValidator(new Zend_Validate_Digits()); $chain->addValidator(new Zend_Validate_GreaterThan(array('min' => ($value-1)))); var_dump($chain->isValid($value), $chain->getMessages()); 

I think, as far as you know, ZF. It would not hurt to receive a function request. It would be nice. Otherwise, GreaterThan and add a parameter.

+3
source

All Articles