fix: fixed cost field validation
This commit is contained in:
parent
1b1c1ce312
commit
dcaae0b481
1 changed files with 2 additions and 1 deletions
|
@ -34,6 +34,7 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.vaadin.klaudeta.PaginatedGrid;
|
import org.vaadin.klaudeta.PaginatedGrid;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -129,8 +130,8 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
||||||
binder.forField(cost)
|
binder.forField(cost)
|
||||||
.asRequired("Cost is required")
|
.asRequired("Cost is required")
|
||||||
.withConverter(new StringToBigDecimalConverter("Invalid cost"))
|
.withConverter(new StringToBigDecimalConverter("Invalid cost"))
|
||||||
|
.withValidator(costValue -> costValue.compareTo(BigDecimal.ONE) > 0, "Cost must be greater than 1")
|
||||||
.bind(Expense::getCost, Expense::setCost);
|
.bind(Expense::getCost, Expense::setCost);
|
||||||
|
|
||||||
binder.forField(category)
|
binder.forField(category)
|
||||||
.asRequired("Category is required")
|
.asRequired("Category is required")
|
||||||
.bind(Expense::getCategory, Expense::setCategory);
|
.bind(Expense::getCategory, Expense::setCategory);
|
||||||
|
|
Loading…
Reference in a new issue