|
|
@@ -43,8 +43,10 @@ public class TestModel extends BaseModel { |
|
|
|
|
|
|
|
public void valid(){ |
|
|
|
MyViolationException mve = new MyViolationException(); |
|
|
|
// if(name == null || "".equals(name)) mve.addViolation("name","姓名不能为空"); |
|
|
|
if(!StringTools.hasText(name)) mve.addViolation("name","姓名不能为空"); |
|
|
|
if(null == age) mve.addViolation("age", "年龄不能为空"); |
|
|
|
// if(gender == null || "".equals(gender)) mve.addViolation("gender", "性别不能为空"); |
|
|
|
if(!StringTools.hasText(gender)) mve.addViolation("gender", "性别不能为空"); |
|
|
|
if(mve.hasViolation()) throw mve; |
|
|
|
} |