This commit is contained in:
guillaume91 2024-05-21 17:06:29 +02:00
parent 0a37fd2d91
commit 025f306d49
3 changed files with 16 additions and 7 deletions

View file

@ -214,7 +214,7 @@ private function validateForm()
'name' => $this->formData['name'],
'pivot_file' => $this->pivotFiles[0] ?? null,
'span_file' => $this->spanFiles[0] ?? null,
'harvest_data_file' => $this->harvestDataFiles[0] ?? null,
'harvest_file' => $this->harvestDataFiles[0] ?? null,
'boundingBoxes' => $this->formData['boundingBoxes'],
], [
'name' => [
@ -223,9 +223,17 @@ private function validateForm()
'string',
'max:255'
],
'pivot_file' => ['sometimes'],
'span_file' => ['sometimes'],
'harvestDataFile' => ['sometimes',new HarvestFile],
'pivot_file.extension' => ['sometimes',function ($attribute, $value, $fail) {
if($value != 'json'){
$fail('Not a json file');
}
}],
'span_file' => ['sometimes',function ($attribute, $value, $fail) {
if($value != 'json'){
$fail('Not a json file');
}
}],
'harvest_file' => ['sometimes',new HarvestFile],
'boundingBoxes' => ['required', 'array', 'min:1'],
'boundingBoxes.*.name' => ['required', 'string', 'max:255'],
'boundingBoxes.*.top_left_latitude' => ['required', 'string'],

View file

@ -14,6 +14,7 @@ class HarvestFile implements ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
//
$extensions = [''];
}
}

View file

@ -60,9 +60,9 @@
<livewire:dropzone
wire:model="harvestDataFiles"
:rules="['extensions:xls,xlsx,ods','mimes:xls,xlsx,ods','required']"
:key="'harvestDataFiles'"
:key="'harvest_file'"
/>
@error('harvestDataFiles')
@error('harvest_file')
{{ $message }}
@enderror
</div>