Browse Source

商城端身份证号添加校验业务功能

multiwx
dy-hu 7 months ago
parent
commit
49ae890e6a
  1. 27
      cereshop-commons/src/main/java/com/shop/cereshop/commons/utils/ValidationUtil.java

27
cereshop-commons/src/main/java/com/shop/cereshop/commons/utils/ValidationUtil.java

@ -5,6 +5,9 @@
*/
package com.shop.cereshop.commons.utils;
import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@ -21,6 +24,15 @@ import java.util.stream.Stream;
public class ValidationUtil {
/**
* 验证是否为邮箱
* @param email
* @return
*/
public static boolean isEmail(String email) {
return new EmailValidator().isValid(email, null);
}
/**
* 身份证号码校验
*/
private static final Map<String, String> cityMap = Stream.of(new String[][] {
@ -105,4 +117,19 @@ public class ValidationUtil {
return null;
}
/**
* 检测价格区间
* @param price
* @param min
* @param max
* @return
*/
public static boolean checkPrice(BigDecimal price, BigDecimal min, BigDecimal max) {
if (price == null || min == null || max == null) {
return false;
}
return price.compareTo(min) >= 0 && price.compareTo(max) <= 0;
}
}
Loading…
Cancel
Save