forked from plusone/plusone-validator
chore: 更新 README 中的示例
This commit is contained in:
parent
5603b72897
commit
8be8be8f17
@ -57,11 +57,12 @@ class CustomerMapValidator extends MapValidator<String, Object> {
|
|||||||
|
|
||||||
private static final CustomerMapValidator INSTANCE = new CustomerMapValidator();
|
private static final CustomerMapValidator INSTANCE = new CustomerMapValidator();
|
||||||
|
|
||||||
private static final String[] FIELD_NAMES = {
|
private static final String[] FIELD_NAMES = {
|
||||||
"name", "emailAddress", "vipLevel", "customerId", "birthday", "address"
|
"name", "emailAddress", "vipLevel", "customerId", "birthday", "address"
|
||||||
};
|
};
|
||||||
|
|
||||||
private CustomerMapValidator() {
|
private CustomerMapValidator() {
|
||||||
|
// validateAndCopy() 时默认保留的 key
|
||||||
super(FIELD_NAMES);
|
super(FIELD_NAMES);
|
||||||
|
|
||||||
ruleForString("name").notBlank("姓名不能为空");
|
ruleForString("name").notBlank("姓名不能为空");
|
||||||
@ -92,7 +93,7 @@ class CustomerMapValidator extends MapValidator<String, Object> {
|
|||||||
使用:
|
使用:
|
||||||
```java
|
```java
|
||||||
public void foo(Map<String, Object> customer) {
|
public void foo(Map<String, Object> customer) {
|
||||||
CustomerMapValidator.getInstance().validate(customer);
|
Map<String, Object> validatedCustomer = CustomerMapValidator.getInstance().validateAndCopy(customer);
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user