fix(voucher): menerapkan custom rule integer dan big integer
This commit is contained in:
parent
59d7e8da2c
commit
270a23f656
@ -5,6 +5,7 @@
|
|||||||
use App\Enums\IsActive;
|
use App\Enums\IsActive;
|
||||||
use App\Enums\VoucherType;
|
use App\Enums\VoucherType;
|
||||||
use App\Models\Voucher;
|
use App\Models\Voucher;
|
||||||
|
use App\Rules\UnsignedInteger;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Livewire\Form;
|
use Livewire\Form;
|
||||||
|
|
||||||
@ -53,19 +54,19 @@ public function rules(): array
|
|||||||
Rule::when(
|
Rule::when(
|
||||||
fn () => $this->type == VoucherType::PERCENTAGE->value,
|
fn () => $this->type == VoucherType::PERCENTAGE->value,
|
||||||
['integer', 'between:0,100'],
|
['integer', 'between:0,100'],
|
||||||
['numeric'],
|
['numeric', new UnsignedInteger],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'min_purchase' => ['nullable', 'numeric'],
|
'min_purchase' => ['nullable', 'numeric', new UnsignedInteger],
|
||||||
'max_discount' => [
|
'max_discount' => [
|
||||||
Rule::when(
|
Rule::when(
|
||||||
fn () => $this->type == VoucherType::PERCENTAGE->value,
|
fn () => $this->type == VoucherType::PERCENTAGE->value,
|
||||||
['required', 'numeric', 'between:0,100'],
|
['required', 'numeric', new UnsignedInteger],
|
||||||
['nullable'],
|
['nullable'],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'quota' => ['nullable', 'numeric'],
|
'quota' => ['nullable', 'numeric', new UnsignedInteger],
|
||||||
'limit_per_user' => ['nullable', 'numeric'],
|
'limit_per_user' => ['nullable', 'numeric', new UnsignedInteger],
|
||||||
'start_date' => ['required', 'date'],
|
'start_date' => ['required', 'date'],
|
||||||
'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
|
'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
|
||||||
'terms_conditions' => ['nullable', 'string'],
|
'terms_conditions' => ['nullable', 'string'],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user