public function setPasUsu($passwordUsuario) { if (SpoonFilter::isSmallerThan(40, strlen($passwordUsuario)) && SpoonFilter::isString($passwordUsuario) && SpoonFilter::isAlphaNumeric($passwordUsuario)) { $this->passwdUsu = sha1($passwordUsuario); } else { echo "Introduzca una contraseña correcta, use sólo números y letras"; exit; } }
public function testIsSmallerThan() { $this->assertFalse(SpoonFilter::isSmallerThan(1, 10)); $this->assertFalse(SpoonFilter::isSmallerThan(-10, -1)); $this->assertFalse(SpoonFilter::isSmallerThan(-1, 10)); $this->assertTrue(SpoonFilter::isSmallerThan(1, -10)); $this->assertFalse(SpoonFilter::isSmallerThan(0, 0)); }
/** * Checks if the field is smaller than a given maximum. * * @return bool * @param int $maximum The maximum. * @param string[optional] $error The error message to set. */ public function isSmallerThan($maximum, $error = null) { // filled if ($this->isFilled()) { // post/get data $data = $this->getMethod(true); // validate if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isSmallerThan($maximum, $data[$this->attributes['name']])) { if ($error !== null) { $this->setError($error); } return false; } return true; } // not submitted if ($error !== null) { $this->setError($error); } return false; }