/** * {@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)); }