This commit is contained in:
Marek Lenczewski
2026-03-31 18:09:15 +02:00
parent b6a4548732
commit b998940caa
48 changed files with 717 additions and 816 deletions

View File

@@ -14,11 +14,8 @@ class CreateSchemaRequest
public ?int $categoryId = null;
public ?string $status = null;
public ?string $taskType = null;
public ?string $deadline = null;
public ?string $type = null;
public ?string $startDate = null;
public ?string $endDate = null;
public ?array $weekdays = null;
public ?array $monthDays = null;
public ?array $yearDays = null;
public ?array $days = null;
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\DTO\Request;
use Symfony\Component\Validator\Constraints as Assert;
class CreateTaskRequest
{
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
public ?string $name = null;
public ?int $categoryId = null;
public ?string $date = null;
}

View File

@@ -8,7 +8,7 @@ trait SchemaValidationTrait
{
public function validate(ExecutionContextInterface $context): void
{
if ($this->taskType !== null && $this->taskType !== 'einzel') {
if ($this->type !== null && $this->type !== 'single') {
if ($this->startDate !== null && $this->endDate !== null && $this->endDate < $this->startDate) {
$context->buildViolation('endDate muss >= startDate sein.')
->atPath('endDate')
@@ -16,26 +16,19 @@ trait SchemaValidationTrait
}
}
if ($this->taskType === 'woechentlich') {
if (empty($this->weekdays)) {
$context->buildViolation('weekdays darf nicht leer sein.')
->atPath('weekdays')
if ($this->type === 'single') {
$year = $this->days['year'] ?? null;
if (empty($year)) {
$context->buildViolation('Mindestens ein Datum muss ausgewählt werden.')
->atPath('days')
->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')
if ($this->type === 'custom') {
if (empty($this->days)) {
$context->buildViolation('days darf nicht leer sein.')
->atPath('days')
->addViolation();
}
}

View File

@@ -1,8 +0,0 @@
<?php
namespace App\DTO\Request;
class ToggleRequest
{
public ?string $date = null;
}

View File

@@ -15,11 +15,8 @@ class UpdateSchemaRequest
public ?int $categoryId = null;
public bool $hasCategoryId = false;
public ?string $status = null;
public ?string $taskType = null;
public ?string $deadline = null;
public ?string $type = null;
public ?string $startDate = null;
public ?string $endDate = null;
public ?array $weekdays = null;
public ?array $monthDays = null;
public ?array $yearDays = null;
public ?array $days = null;
}

View File

@@ -1,16 +0,0 @@
<?php
namespace App\DTO\Response;
use Symfony\Component\Serializer\Attribute\Groups;
class DayResponse
{
public function __construct(
#[Groups(['task:read'])]
public readonly string $date,
/** @var \App\Entity\Task[] */
#[Groups(['task:read'])]
public readonly array $tasks,
) {}
}

View File

@@ -1,10 +0,0 @@
<?php
namespace App\DTO\Response;
class ToggleResponse
{
public function __construct(
public readonly bool $completed,
) {}
}

View File

@@ -1,17 +0,0 @@
<?php
namespace App\DTO\Response;
use Symfony\Component\Serializer\Attribute\Groups;
class WeekViewResponse
{
public function __construct(
/** @var \App\Entity\Task[] */
#[Groups(['task:read'])]
public readonly array $tasksWithoutDeadline,
/** @var DayResponse[] */
#[Groups(['task:read'])]
public readonly array $days,
) {}
}