An idea for splitting validation and running
[MAILPOET-4191]
This commit is contained in:
committed by
Veljko V
parent
70911d2424
commit
2cce9bf7ad
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Automation\Engine\Workflows;
|
||||
|
||||
class ActionValidationResult {
|
||||
private $errors = [];
|
||||
private $validated = [];
|
||||
|
||||
public function setValidatedParam(string $key, $value): void {
|
||||
$this->validated[$key] = $value;
|
||||
}
|
||||
|
||||
public function addError(\Exception $exception): void {
|
||||
$this->errors[] = $exception;
|
||||
}
|
||||
|
||||
public function isValid(): bool {
|
||||
return count($this->getErrors()) === 0;
|
||||
}
|
||||
|
||||
public function getErrors(): array {
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
public function hasErrors(): bool {
|
||||
return count($this->getErrors()) > 0;
|
||||
}
|
||||
|
||||
public function getValidatedParams(): array {
|
||||
return $this->validated;
|
||||
}
|
||||
|
||||
public function getValidatedParam(string $key) {
|
||||
return $this->getValidatedParams()[$key] ?? null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user