public function testRangeStrict()
 {
     $validator = new TextLengthValidator(3, 11, TextLengthValidator::MODE_STRICT);
     $this->assertTrue($validator->isValid('Lorem ipsum'));
     $this->assertTrue($validator->isValid('Lorem ipsum  '));
     $this->assertTrue($validator->isValid('  Lorem ipsum'));
     $this->assertFalse($validator->isValid('    '));
     $this->assertFalse($validator->isValid(null));
     $this->assertFalse($validator->isValid('DJ  '));
     $this->assertFalse($validator->isValid('  DJ'));
     $this->assertFalse($validator->isValid('Lorem ipsum dolor'));
 }
示例#2
0
 /**
  * Re-implements the <em>validate()</em> method for the text length validator.
  * Supports min and max length definition of the text to validate.
  *
  * @param string $input The text to validate.
  *
  * @return boolean true, in case the control to validate is considered valid, false otherwise.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 06.02.2010<br />
  * Version 0.2, 23.08.2014 (ID#138: extracted validation to allow unit testing and easy controller validation)<br />
  */
 public function validate($input)
 {
     $validator = new TextLengthValidatorImpl($this->getMinLength(), $this->getMaxLength(), $this->getMode());
     return $validator->isValid($input);
 }