diff --git a/app/Livewire/Forms/VoucherForm.php b/app/Livewire/Forms/VoucherForm.php index 9e3c989..23f3bc7 100644 --- a/app/Livewire/Forms/VoucherForm.php +++ b/app/Livewire/Forms/VoucherForm.php @@ -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'],