Closed takielias closed 2 months ago
@takielias which version of the package are you using?
@rahulhaque
rahulhaque/laravel-filepond": "^11.0
@takielias everything seems to be working fine using only web middleware and your mentioned validation rule. Can you explain in detail so that I can recreate the issue in my end?
Edit: You can either debug by yourself if you're capable or create a demo project with the issue so that I can have a look.
@rahulhaque
'photo' => ['required', Rule::filepond([ 'required', 'image', 'max:10' ])]
If I put any image more than 10KB it should return error. Is that right according to this validation ? But I don't get any error message.
If I put the same validation rule in config file, it works.
@takielias there are two types of validation, server and request level validation explained here. Which one is failing for you?
From what you're saying, it seems you're facing issues with request level validation. As I have said before, share the full code causing the issue so that I can point out the error.
Also, did the "File does not exist" issue solved?
@rahulhaque
This is the full Request Class code. I want server validation.
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class RecordSaveRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [
'photo' => ['required', Rule::filepond([
'required',
'image',
'max:10'
])]
];
}
public function messages()
{
return [
'photo.required' => 'You must submit photo.',
];
}
}
@takielias thanks. For server level validation, you must use the config file which gets validated as soon as the filepond finish uploading the file. Server level validation cannot be dynamic, that's why I came up with request level validation. Request level validation works when you submit the form or do $request->validate()
.
@rahulhaque Thank you for your quick reply.
Always I got after submit
It should throw the validation error.
@takielias That's interesting. Never seen that type of error. Please provide controller's file validation/processing code, your filpond config or anything and everything that will help me to recreate the issue. If concerned about privacy, it is best to create a sample project that has the issue and give me access. There maybe many factors that causing this issue. I can't help you if you keep sharing bits of code here and there out of the context. Be responsible and descriptive.
@takielias did you manage to solve it or create a demo project containing the issue?
@rahulhaque Thanks for your reply. I have managed it by removing the validation part. But it's not a good practice. I will share a demo one.
Closing this issue as there's no meaningful outcome on how to reproduce this issue. Mention me in the comments if something comes up.
This is the validation rule
I'm also using only web middleware because it's a public access.
But, I got a validation error like the following everytime
"File does not exist or is not readable: eyJpdiI6IndaNEx3NVlRc1JhM3FFNVpoSU9pMXc9PSIsInZhbHVlIjoid2VOWmE4WHRWQjhGMTlHOHBNNE12VkZKOVZFcEU5b09tbG15aHhadEw5az0iLCJtYWMiOiIxNDM5MThiNzkyMWQ3MzFmODI5ZTk3ZDQ0MzQxYjQ0ZmViM2Q1OGUwYzc0Y2JhNGU5ODljYjQzNjVjOTVjZDM4IiwidGFnIjoiIn0="