Beispiel #1
0
 public function testVarcharField()
 {
     $this->markTestIncomplete('Failed on travis, not on my laptop');
     $field = new field\Field();
     $this->assertEquals('abc', $field->clean('abc'));
     $params = array('required' => true, 'max_length' => 15, 'min_length' => 3, 'widget_attrs' => array('maxlength' => 15, 'size' => 10));
     $field = new field\Varchar($params);
     $wrong_values = array(array('', 'required'), array('ab', 0), array('1234567890123456', 0));
     // through validators
     foreach ($wrong_values as $v) {
         try {
             $nv = $field->clean($v[0]);
         } catch (Invalid $e) {
             $this->assertEquals($v[1], $e->getCode());
             continue;
         }
         $this->fail(sprintf('This value should be wrong: %s', $v));
     }
     $this->assertEquals('abc', $field->clean('abc'));
 }
Beispiel #2
0
 public function __construct($params = array())
 {
     parent::__construct($params);
     $this->validators[] = function ($value) {
         return validator\Net::macAddress($value);
     };
     $this->widget->attrs['pattern'] = '([0-9A-Fa-f]{2}[:-]{0,1}){5}[0-9A-Fa-f]{2}';
 }