Skip to content

Commit

Permalink
Add validation rule to item price field in RequestForm
Browse files Browse the repository at this point in the history
- Price has to be positive numeric value with max. 2 decimal places.

remp/crm#2817
  • Loading branch information
Matefko committed May 30, 2023
1 parent 2436d30 commit 5d83b84
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Forms/RequestFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public function create(ActiveRow $user): Form
->setHtmlAttribute('placeholder', 'family.admin.form.request.price.label')
->addRule(Form::FLOAT, 'family.admin.form.request.price.number')
->addRule(Form::MIN, 'family.admin.form.request.price.number', 0)
->addRule(Form::PATTERN, 'family.admin.form.request.price.invalid_format', '^\d{1,8}[\.,]?\d{0,2}$')
->addConditionOn($formItems[$id][$item->id]['count'], Form::NOT_EQUAL, 0)
->setRequired('family.admin.form.request.price.required');

Expand Down
1 change: 1 addition & 0 deletions src/lang/family.cs_CZ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ admin:
required: Jednotková cena položky musí být vyplněna
total: Celková cena položek nemůže být nulová
number: Jednotková cena položky musí být kladná číselná hodnota
invalid_format: Jednotková cena položky musí být kladná číselná hodnota s max. 2 desetinnými místy
count:
label: Počet
total: Celkový počet položek nemůže být nulový
Expand Down
1 change: 1 addition & 0 deletions src/lang/family.en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ admin:
required: Item's unit price is required
total: Total price of items cannot be zero
number: Item's unit price has to be positive numeric value
invalid_format: Item's unit price has to be positive numeric value with max. 2 decimal places
count:
label: Count
total: Total count of items cannot be zero
Expand Down
1 change: 1 addition & 0 deletions src/lang/family.sk_SK.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ admin:
required: Jednotková cena položky musí byť vyplnená
total: Celková cena položiek nemôže byť nulová
number: Jednotková cena položky musí byť kladná číselná hodnota
invalid_format: Jednotková cena položky musí byť kladná číselná hodnota s max. 2 desatinnými miestami
count:
label: Počet
total: Celkový počet položiek nemože byť nulový
Expand Down

0 comments on commit 5d83b84

Please sign in to comment.