fix(voucher): menerapkan custom rule integer dan big integer

This commit is contained in:
Yoga Pangestu 2025-09-28 22:18:14 +07:00
parent 59d7e8da2c
commit 270a23f656

View File

@ -5,6 +5,7 @@
use App\Enums\IsActive;
use App\Enums\VoucherType;
use App\Models\Voucher;
use App\Rules\UnsignedInteger;
use Illuminate\Validation\Rule;
use Livewire\Form;
@ -53,19 +54,19 @@ public function rules(): array
Rule::when(
fn () => $this->type == VoucherType::PERCENTAGE->value,
['integer', 'between:0,100'],
['numeric'],
['numeric', new UnsignedInteger],
),
],
'min_purchase' => ['nullable', 'numeric'],
'min_purchase' => ['nullable', 'numeric', new UnsignedInteger],
'max_discount' => [
Rule::when(
fn () => $this->type == VoucherType::PERCENTAGE->value,
['required', 'numeric', 'between:0,100'],
['required', 'numeric', new UnsignedInteger],
['nullable'],
),
],
'quota' => ['nullable', 'numeric'],
'limit_per_user' => ['nullable', 'numeric'],
'quota' => ['nullable', 'numeric', new UnsignedInteger],
'limit_per_user' => ['nullable', 'numeric', new UnsignedInteger],
'start_date' => ['required', 'date'],
'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
'terms_conditions' => ['nullable', 'string'],