/** * {@inheritDoc} */ public function buildRules(RulesChecker $rules) { $rules->addCreate(function () { return $this->find()->count() < 25; }, 'maximumAmount'); return parent::buildRules($rules); }
/** * Test that returnned error messages work. * * @return void */ public function testAddWithoutFields() { $entity = new Entity(['name' => 'larry']); $rules = new RulesChecker(); $rules->add(function () { return false; }); $this->assertFalse($rules->check($entity, RulesChecker::CREATE)); $this->assertEmpty($entity->errors()); }