/** * Implements corresponding isValidXX logic. * * @param string $context Please see corresponding isValidXX description. * @param string $input Please see corresponding isValidXX description. * @param int $minValue Please see corresponding isValidXX description. * @param int $maxValue Please see corresponding isValidXX description. * @param bool $allowNull Please see corresponding isValidXX description. * * @return does not return a value. * @throws ValidationException thrown if input is invalid. * @throws IntrusionException thrown if intrusion is detected. */ private function _assertValidNumber($context, $input, $minValue, $maxValue, $allowNull) { $nvr = new NumberValidationRule('NumberValidator', $this->_encoder, $minValue, $maxValue); $nvr->setAllowNull($allowNull); $nvr->assertValid($context, $input); return null; }
/** * getValid does not treat '0' as empty. disallows empty values when * allowNull is false. */ function testNumberVR_getValid_Empty() { $nvr = new NumberValidationRule('A_Number', null); $this->assertTrue($nvr->isValid('testNumberVR_getValid_Empty', '0')); $this->assertFalse($nvr->isValid('testNumberVR_getValid_Empty', '')); $this->assertFalse($nvr->isValid('testNumberVR_getValid_Empty', null)); $nvr->setAllowNull(true); $this->assertTrue($nvr->isValid('testNumberVR_getValid_Empty', '')); $this->assertTrue($nvr->isValid('testNumberVR_getValid_Empty', null)); }