栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

20220530之JAVA第三方工具包hutool集成了手机号邮箱校验+验证码+超多实用工具类

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

20220530之JAVA第三方工具包hutool集成了手机号邮箱校验+验证码+超多实用工具类

Background:

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~~~~

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/936995.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号