public function validate() { $validator = new Validator(); $validator->importRow('name', $this->name, ['IsNotEmpty'])->importRow('slug', $this->slug, ['IsNotEmpty', 'IsSlug'])->importRow('content', $this->content, ['IsNotEmpty'])->run(); $errors = $validator->getErrors(); if (false === empty($errors)) { throw new ValidationException($errors); } }
public function validator() { $validator = new Validator(); $validator->importRow('name', $this->name, ['IsNotEmpty'])->importRow('slug', $this->slug, ['IsNotEmpty', 'IsSlug'])->importRow('content', $this->content, ['IsNotEmpty'])->run(); return $validator; }