/** * Check array notation for validators */ public function testValidatorsGivenArrayKeysOnValidation() { $username = new Element('username'); $username->addValidator('stringLength', true, array('min' => 5, 'max' => 20, 'ignore' => 'something')); $form = new Form(array('elements' => array($username))); $this->assertTrue($form->isValid(array('username' => 'abcde'))); }
public function setupElement() { $element = new Element('foo'); $element->addValidator('Alnum')->addValidator('Alpha')->setView($this->getView()); $element->isValid('abc-123'); $this->element = $element; $this->decorator->setElement($element); }
/** * @group ZF-2862 */ public function testBreakChainOnFailureFlagsForExistingValidatorsRemainSetWhenNotEmptyValidatorAutoInserted() { $username = new Element('username'); $username->addValidator('stringLength', true, array(5, 20))->addValidator('regex', true, array('/^[a-zA-Z0-9_]*$/'))->addFilter('StringToLower')->setRequired(true); $form = new Form(array('elements' => array($username))); $form->isValid(array('username' => '#')); $validator = $username->getValidator('stringLength'); $this->assertTrue($validator->zfBreakChainOnFailure); $validator = $username->getValidator('regex'); $this->assertTrue($validator->zfBreakChainOnFailure); }