Exemplo n.º 1
0
 public function testIsDigital()
 {
     $this->assertTrue(SpoonFilter::isDigital('010192029'));
     $this->assertTrue(SpoonFilter::isDigital(1337));
     $this->assertFalse(SpoonFilter::isDigital('I can has cheezeburger'));
     $this->assertFalse(SpoonFilter::isDigital(array()));
 }
Exemplo n.º 2
0
Arquivo: text.php Projeto: szLuis/oac
 /**
  * Checks if this field only contains numbers 0-9.
  *
  * @return	bool
  * @param	string[optional] $error		The error message to set.
  */
 public function isDigital($error = null)
 {
     // filled
     if ($this->isFilled()) {
         // post/get data
         $data = $this->getMethod(true);
         // validate
         if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isDigital($data[$this->attributes['name']])) {
             if ($error !== null) {
                 $this->setError($error);
             }
             return false;
         }
         return true;
     }
     // not submitted
     if ($error !== null) {
         $this->setError($error);
     }
     return false;
 }