update
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
class UpdateSchemaRequest
|
||||
{
|
||||
use SchemaValidationTrait;
|
||||
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $name = null;
|
||||
@@ -21,40 +22,4 @@ class UpdateSchemaRequest
|
||||
public ?array $weekdays = null;
|
||||
public ?array $monthDays = null;
|
||||
public ?array $yearDays = null;
|
||||
|
||||
#[Assert\Callback]
|
||||
public function validate(ExecutionContextInterface $context): void
|
||||
{
|
||||
if ($this->taskType !== null && $this->taskType !== 'einzel') {
|
||||
if ($this->startDate !== null && $this->endDate !== null && $this->endDate < $this->startDate) {
|
||||
$context->buildViolation('endDate muss >= startDate sein.')
|
||||
->atPath('endDate')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'woechentlich') {
|
||||
if (empty($this->weekdays)) {
|
||||
$context->buildViolation('weekdays darf nicht leer sein.')
|
||||
->atPath('weekdays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'monatlich') {
|
||||
if (empty($this->monthDays)) {
|
||||
$context->buildViolation('monthDays darf nicht leer sein.')
|
||||
->atPath('monthDays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'multi' || $this->taskType === 'jaehrlich') {
|
||||
if (empty($this->yearDays)) {
|
||||
$context->buildViolation('yearDays darf nicht leer sein.')
|
||||
->atPath('yearDays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user