I am learning about the application of Redis. While a new user signup in App,he(or she) should fill the phone number to receive CAPTCHA to verify identification. Thus, we need some utils help ourselves to save time. Here I found 2 package of dependencies and would like to share.
- hutool
cn.hutool hutool-all 5.7.17
- apache-commons-validator
commons-validator commons-validator 1.7
- commons-validator除了通用验证方法外,还支持国际通用数字标准验证,比如:IBAN (International Bank Account Number)、ISSN(International Standard Serial Number)、ISBN(International Standard Book Number)等
- hutool(Validator)通用验证方法与commons-validator基本一致,由于国人开源,验证方法较“中国”化些,比如:身份证、手机号、车牌号、邮政编码、社会统一信用代码、是否汉字等。
Assert.Class // assert if something must be true/false, if not,throw exception Validator.Class //to validate mobile ,email and etc....
Codes reference as below:
@Test
void test(){
String number="123456789";
String email ="12sdsdada2@qq.com";
boolean mobile = Validator.isMobile(number);
boolean a = Validator.isEmail(email);
System.out.println(mobile);
System.out.println(a);
}
// false
// true
hutool is developed by Chinese——so it’s really convenient if you worked and developed in China.
There are lots of methods waiting for you to discover~~~~



