Skip to content

Commit

Permalink
fix: validation rules for files (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio authored Jul 5, 2024
1 parent 36ff9f8 commit d01e11c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/Http/Requests/Organization/UpdateOrganizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function rules(): array
return [
'name' => ['nullable', 'string'],
'description' => ['nullable', 'string'],
'logo' => ['nullable', 'file', 'mimes:jpg,png'],
'statute' => ['nullable', 'file', 'mimes:pdf'],
'logo' => ['nullable', 'image', 'max:2048'],
'statute' => ['nullable', 'file', 'mimes:pdf', 'max:15360'],
'address' => ['nullable', 'string'],
'cif' => ['nullable', 'string', 'unique:organizations,cif', new ValidCIF],
'contact_email' => ['nullable', 'email'],
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Requests/Project/EditRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace App\Http\Requests\Project;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\File;

class EditRequest extends FormRequest
{
Expand Down Expand Up @@ -38,8 +37,8 @@ public function rules(): array
'external_links.*.url' => ['required', 'url'],
'is_national' => ['boolean', 'nullable'],
'gallery' => ['array', 'nullable'],
'gallery.*.file' => ['file', 'nullable', File::image()->max(5000)->extensions(['png', 'jpg', 'jpeg'])],
'image' => ['file', File::image()->max('5mb')->extensions(['png', 'jpg', 'jpeg']), 'nullable'],
'gallery.*.file' => ['nullable', 'image', 'max:5120'],
'image' => ['nullable', 'image', 'max:5120'],
];
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/Project/StoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public function rules(): array

'is_national' => ['boolean', 'nullable'],
'gallery' => ['array', 'nullable'],
'gallery.*.file' => ['file', 'nullable'],
'preview' => ['file', 'nullable'],
'gallery.*.file' => ['nullable', 'image', 'max:5120'],
'preview' => ['nullable', 'image', 'max:5120'],
];
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/RegistrationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function rules(): array
'ngo' => ['required', 'array'],
'ngo.name' => ['required', 'string'],
'ngo.description' => ['required', 'string', 'max:1000'],
'ngo.logo' => ['required', 'image'],
'ngo.statute' => ['required', 'file', 'mimes:pdf', 'max:15240'],
'ngo.logo' => ['required', 'image', 'max:2048'],
'ngo.statute' => ['required', 'file', 'mimes:pdf', 'max:15360'],
'ngo.address' => ['required', 'string'],
'ngo.cif' => ['required', 'string', 'unique:organizations,cif', new ValidCIF],
'ngo.contact_email' => ['required', 'email'],
Expand Down
2 changes: 1 addition & 1 deletion config/media-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* The maximum file size of an item in bytes.
* Adding a larger file will result in an exception.
*/
'max_file_size' => 1024 * 1024 * 10, // 10MB
'max_file_size' => 1024 * 1024 * 20, // 20MB

/*
* This queue connection will be used to generate derived and responsive images.
Expand Down

0 comments on commit d01e11c

Please sign in to comment.