Skip to content

Commit cd77f65

Browse files
committed
@min & @max validation
1 parent 2548891 commit cd77f65

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

Spring MVC/WebContent/WEB-INF/view/customer-form.jsp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
<form:errors path="lastname" cssClass="error"/>
2525
<br>
2626

27+
Last Name: <form:input path="pass" placeholder="Enter pass"/>
28+
<form:errors path="pass" cssClass="error"/>
29+
<br>
30+
2731
<input type="submit" value="Submit"/>
2832

2933
</form:form>

Spring MVC/WebContent/WEB-INF/view/customer.jsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<body>
1212

1313
<h2>Customer is confirmed : ${customer.firstname} ${customer.lastname}</h2>
14+
<h2>Pass : ${customer.pass} </h2>
1415

1516
</body>
1617
</html>
Binary file not shown.

Spring MVC/src/com/udemy/spring/validation/Customer.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
package com.udemy.spring.validation;
22

3+
import javax.validation.constraints.Max;
4+
import javax.validation.constraints.Min;
35
import javax.validation.constraints.NotNull;
46
import javax.validation.constraints.Size;
57

68
public class Customer {
79

10+
811
private String firstname;
912

1013
@NotNull()
1114
@Size(min=2, message="Size must be > than 2")
1215
private String lastname;
1316

17+
@Min(value=1)
18+
@Max(value=10)
19+
private int pass;
20+
21+
1422

23+
public int getPass() {
24+
return pass;
25+
}
26+
public void setPass(int pass) {
27+
this.pass = pass;
28+
}
1529
public String getFirstname() {
1630
return firstname;
1731
}

0 commit comments

Comments
 (0)