目前内置了常见的几种类型:身份证号、手机号、固定电话、邮箱、IP地址

    ID_CARD :身份证号 PHONE_NUM :手机号 FIXED_PHONE :固定电话 MAIL :邮箱 IP_ADDRESS: IP地址

    1. @Data
    2. @Accessors(chain = true)
    3. public class IpEntity {
    4. @Matcher(model = FieldModel.IP_ADDRESS)
    5. private String ipValid;
    6. @Matcher(model = FieldModel.IP_ADDRESS, accept =false)
    7. private String ipInvalid;
    8. }
    1. def "IP测试"() {
    2. given:
    3. IpEntity entity = new IpEntity().setIpValid(valid).setIpInvalid(invalid)
    4. expect:
    5. boolean actResult = MkValidators.check(entity)
    6. if (!result) {
    7. println MkValidators.getErrMsgChain()
    8. }
    9. Assert.assertEquals(result, actResult)
    10. where:
    11. valid | invalid | result
    12. "192.231asdf" | "192.123.231.222" | false
    13. "192.231asdf" | "192.231asdf" | false
    14. "192.123.231.222" | "192.231asdf" | true
    15. "192.123.231.222" | "192.123.231.222" | false
    16. }