Refactor to use ItemInformativeValidatorByNameFactory.
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-08-28 14:28:14 +03:00
parent 9a83b398c0
commit 36a803131e
6 changed files with 8 additions and 46 deletions
@@ -36,12 +36,12 @@ abstract class InformativeValidator extends Validator {
return $this->nextValidator->getMessage();
}
public function okStatus(): array
public function getOkStatus(): array
{
if(!$this->isCurrentValid())
return ['error' => $this->message];
return $this->nextValidator->okStatus();
return $this->nextValidator->getOkStatus();
}
}
@@ -1,20 +0,0 @@
<?php
namespace App\Models\Validation\Messages;
use App\Models\Validation\Messages\BaseMessages;
class ItemMessagesFactory
{
protected array $messages = [
'found' => 'A item with the name is valid.',
'not_found' => 'A item with the name does not exist!!!',
'invalid_name' => 'The item name is empty, please, write the name!!!',
];
public function create()
{
return new BaseMessages($this->messages);
}
}
@@ -17,7 +17,7 @@ class OkInformativeValidator extends InformativeValidator {
return $this->message;
}
public function okStatus(): array
public function getOkStatus(): array
{
return ['ok' => $this->getMessage()];
}