Ejemplo n.º 1
0
 /**
  * Every static call of exist Rule should be return a new instance of Validator
  */
 public function testStaticCallsShouldReturnNewValidator()
 {
     $this->assertInstanceOf('Bluz\\Validator\\Validator', Validator::arrayInput(function () {
         return true;
     }));
     $this->assertInstanceOf('Bluz\\Validator\\Validator', Validator::string());
     $this->assertInstanceOf('Bluz\\Validator\\Validator', Validator::notEmpty());
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * @return void
  */
 public function beforeSave()
 {
     // title validator
     $this->addValidator('title', v::required(), v::length(2, 128));
     //description validator
     $this->addValidator('description', v::required(), v::length(2, 250), v::string());
     //category validator
     $this->addValidator('categoryId', v::required(), v::integer());
     //cost validator
     $this->addValidator('cost', v::required(), v::float(), v::min(0.01, true));
 }