/** * Checks if this field's length is more than or equal to the given minimum. * * @return bool * @param int $minimum The minimum number of characters. * @param string[optional] $error The error message to set. */ public function isMinimumCharacters($minimum, $error = null) { // filled if ($this->isFilled()) { // post/get data $data = $this->getMethod(true); // validate if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isMinimumCharacters($minimum, $data[$this->attributes['name']])) { if ($error !== null) { $this->setError($error); } return false; } return true; } // not submitted if ($error !== null) { $this->setError($error); } return false; }
public function testIsMinimumCharacters() { $string = 'Ik heb er géén gedacht van'; $this->assertTrue(SpoonFilter::isMinimumCharacters(10, $string, 'utf-8')); $this->assertFalse(SpoonFilter::isMinimumCharacters(30, $string, 'utf-8')); $this->assertTrue(SpoonFilter::isMinimumCharacters(10, utf8_decode($string), 'iso-8859-1')); }