update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
15
backend/src/DTO/Request/CreateTaskRequest.php
Normal file
15
backend/src/DTO/Request/CreateTaskRequest.php
Normal 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;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
class ToggleRequest
|
||||
{
|
||||
public ?string $date = null;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
) {}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Response;
|
||||
|
||||
class ToggleResponse
|
||||
{
|
||||
public function __construct(
|
||||
public readonly bool $completed,
|
||||
) {}
|
||||
}
|
||||
@@ -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,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user