public class ValidateTools extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
assertValidateEntity(T obj) |
static <T> void |
assertValidateEntityWithoutFieldName(T obj) |
static boolean |
isAge(int age)
匹配年龄
|
static boolean |
isBankCardNo(String text)
验证银行卡
15-19位数字
|
static boolean |
isChinese(String text)
匹配汉字
|
static boolean |
isChineseChar(String text)
判断中文字符(包括汉字和符号)
|
static boolean |
isDigits(String str)
匹配正整数
|
static boolean |
isEmail(String str)
匹配Email地址
|
static boolean |
isFloat(String str)
匹配正浮点数
|
static boolean |
isIdCardNo(String text)
身份证号码验证
|
static boolean |
isIp(String ipAddress) |
static boolean |
isLetter(String text)
判断英文字母(a-zA-Z)
|
static boolean |
isMobile(String text)
手机号校验
|
static boolean |
isName(String name)
匹配姓名
|
static boolean |
isNumeric(String str)
匹配数值类型,包括整数和浮点数
|
static boolean |
isUrl(String str)
匹配URL地址
|
static boolean |
matches(String text,
String regex)
正则匹配
|
static boolean |
max(int max,
int value)
最大
|
static boolean |
maxLength(int max,
String str)
是否小于等于最大长度
|
static boolean |
min(int min,
int value)
最小
|
static boolean |
minLength(int min,
String str)
是否大于等于最小长度
|
static boolean |
range(int min,
int max,
int value)
大小范围
|
static boolean |
rangeLength(int min,
int max,
String str)
长度范围
|
static <T> ValidationResult |
validateEntity(T obj)
校验实体,返回实体所有属性的校验结果
|
static <T> ValidationResult |
validateProperty(T obj,
String propertyName)
校验指定实体的指定属性是否存在异常
|
public static boolean isAge(int age)
age - public static boolean isName(String name)
name - public static boolean isChineseChar(String text)
text - public static boolean isChinese(String text)
text - public static boolean isLetter(String text)
text - public static boolean isDigits(String str)
str - public static boolean isFloat(String str)
str - public static boolean isNumeric(String str)
str - public static boolean isUrl(String str)
str - public static boolean min(int min,
int value)
min - value - public static boolean max(int max,
int value)
max - value - public static boolean range(int min,
int max,
int value)
min - max - value - public static boolean minLength(int min,
String str)
min - str - public static boolean maxLength(int max,
String str)
max - str - public static boolean rangeLength(int min,
int max,
String str)
min - 最小max - 最大str - 字符串public static boolean isMobile(String text)
text - public static boolean isEmail(String str)
str - public static boolean isBankCardNo(String text)
text - public static boolean isIdCardNo(String text)
text - public static <T> void assertValidateEntity(T obj)
public static <T> void assertValidateEntityWithoutFieldName(T obj)
public static <T> ValidationResult validateEntity(T obj)
T - obj - public static <T> ValidationResult validateProperty(T obj, String propertyName)
T - obj - propertyName - public static boolean isIp(String ipAddress)
Copyright © 2022. All rights reserved.