Stricter validation for uuid and integer

This commit is contained in:
Constantin Graf
2024-10-15 10:59:53 +02:00
committed by Constantin Graf
parent 2b1da883fb
commit 69d3ff4f7b
31 changed files with 187 additions and 122 deletions

View File

@@ -31,11 +31,10 @@ class TimeEntryIndexRequest extends FormRequest
// Filter by member ID
'member_id' => [
'string',
'uuid',
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
ExistsEloquent::make(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
})->uuid(),
],
// Filter by multiple member IDs, member IDs are OR combined, but AND combined with the member_id parameter
'member_ids' => [
@@ -44,11 +43,10 @@ class TimeEntryIndexRequest extends FormRequest
],
'member_ids.*' => [
'string',
'uuid',
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
ExistsEloquent::make(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
})->uuid(),
],
// Filter by client IDs, client IDs are OR combined
'client_ids' => [
@@ -57,11 +55,10 @@ class TimeEntryIndexRequest extends FormRequest
],
'client_ids.*' => [
'string',
'uuid',
new ExistsEloquent(Client::class, null, function (Builder $builder): Builder {
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
/** @var Builder<Client> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
})->uuid(),
],
// Filter by project IDs, project IDs are OR combined
'project_ids' => [
@@ -70,11 +67,10 @@ class TimeEntryIndexRequest extends FormRequest
],
'project_ids.*' => [
'string',
'uuid',
new ExistsEloquent(Project::class, null, function (Builder $builder): Builder {
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
/** @var Builder<Project> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
})->uuid(),
],
// Filter by tag IDs, tag IDs are AND combined
'tag_ids' => [
@@ -83,11 +79,10 @@ class TimeEntryIndexRequest extends FormRequest
],
'tag_ids.*' => [
'string',
'uuid',
new ExistsEloquent(Tag::class, null, function (Builder $builder): Builder {
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
/** @var Builder<Tag> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
})->uuid(),
],
// Filter by task IDs, task IDs are OR combined
'task_ids' => [
@@ -96,11 +91,10 @@ class TimeEntryIndexRequest extends FormRequest
],
'task_ids.*' => [
'string',
'uuid',
new ExistsEloquent(Task::class, null, function (Builder $builder): Builder {
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
/** @var Builder<Task> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
})->uuid(),
],
// Filter only time entries that have a start date after the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
'start' => [
@@ -135,6 +129,7 @@ class TimeEntryIndexRequest extends FormRequest
'offset' => [
'integer',
'min:0',
'max:2147483647',
],
// Filter makes sure that only time entries of a whole date are returned
'only_full_dates' => [