diff --git a/app/Http/Controllers/AuthorEmploymentController.php b/app/Http/Controllers/AuthorEmploymentController.php index 1b7eb88e..086912b3 100644 --- a/app/Http/Controllers/AuthorEmploymentController.php +++ b/app/Http/Controllers/AuthorEmploymentController.php @@ -33,8 +33,8 @@ public function store(Author $author, Request $request) $validated = $request->validate([ 'organization_id' => 'nullable|exists:organizations,id', - 'role_title' => 'nullable|string|max:255', - 'department_name' => 'nullable|string|max:255', + 'role_title' => 'nullable|string|max:125', + 'department_name' => 'nullable|string|max:125', 'start_date' => 'required|date', 'end_date' => 'nullable|date', ]); @@ -81,8 +81,8 @@ public function update(Author $author, Request $request, AuthorEmployment $autho $this->authorize('update', $authorEmployment); $validated = $request->validate([ - 'role_title' => 'nullable|string|max:50', - 'department_name' => 'nullable|string|max:50', + 'role_title' => 'nullable|string|max:125', + 'department_name' => 'nullable|string|max:125', 'start_date' => 'required|date', 'end_date' => 'nullable|date', ]); diff --git a/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue b/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue index b1eb5ec8..30f95635 100644 --- a/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue +++ b/resources/src/models/AuthorEmployment/components/AddAuthorEmploymentDialog.vue @@ -65,7 +65,7 @@ async function createAuthorEmployment() { :label="t('orcid-employment-edit.role-title')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]), + (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), ]" class="q-mb-md" /> @@ -74,7 +74,7 @@ async function createAuthorEmployment() { :label="t('orcid-employment-edit.department-name')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]), + (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), ]" class="q-mb-md" :hint="t('orcid-employment-edit.department-name-hint')" diff --git a/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue b/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue index a315aab6..70b2e0cc 100644 --- a/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue +++ b/resources/src/models/AuthorEmployment/components/EditAuthorEmploymentDialog.vue @@ -78,7 +78,7 @@ function deleteAuthorEmployment() { :label="t('orcid-employment-edit.role-title')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]), + (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), ]" class="q-mb-md" /> @@ -87,7 +87,7 @@ function deleteAuthorEmployment() { :label="t('orcid-employment-edit.department-name')" outlined :rules="[(val: string|null) => !!val || t('common.required'), - (val: string) => val.length <= 255 || t('common.validation.must-be-less-than-x-characters', [255]), + (val: string) => val.length <= 125 || t('common.validation.must-be-less-than-x-characters', [125]), ]" class="q-mb-md" :hint="t('orcid-employment-edit.department-name-hint')" diff --git a/tests/Feature/Models/AuthorEmployementTest.php b/tests/Feature/Models/AuthorEmployementTest.php index 165a7da5..691f2f04 100644 --- a/tests/Feature/Models/AuthorEmployementTest.php +++ b/tests/Feature/Models/AuthorEmployementTest.php @@ -119,3 +119,24 @@ Queue::assertPushed(\App\Jobs\SyncAuthorEmploymentWithOrcid::class); }); + +test('adding a 125 char role title is valid', function () { + $user = User::factory()->create(); + $employment = AuthorEmployment::factory()->create([ + 'author_id' => $user->author->id, + 'organization_id' => Organization::getDefaultOrganization()->id, + 'start_date' => now()->subYear(), + ]); + + $data = AuthorEmployment::factory()->make([ + 'author_id' => $user->author->id, + 'organization_id' => Organization::getDefaultOrganization()->id, + 'start_date' => now()->subYear(), + 'role_title' => str_repeat('a', 125), + ])->toArray(); + + $response = $this->actingAs($user)->putJson("api/authors/{$user->author->id}/employments/{$employment->id}", $data)->assertOk(); + + expect($response->json('data.role_title'))->toBe(str_repeat('a', 125)); + +});