From 339df65ba5a2826851660d22f909aa15da7e073e Mon Sep 17 00:00:00 2001 From: liqiang <1144388620@qq.com> Date: Fri, 29 Jan 2021 22:40:07 +0800 Subject: [PATCH] fixed 1.1.0 --- .../github/liangbaika/validate/core/ValidateBuilder.java | 8 +------- .../java/com/github/liangbaika/validate/test/Tests.java | 5 +++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/liangbaika/validate/core/ValidateBuilder.java b/src/main/java/com/github/liangbaika/validate/core/ValidateBuilder.java index 73df88b..65623bd 100644 --- a/src/main/java/com/github/liangbaika/validate/core/ValidateBuilder.java +++ b/src/main/java/com/github/liangbaika/validate/core/ValidateBuilder.java @@ -201,13 +201,7 @@ public int getFailedCounts() { * @return int */ public int getSuccedCounts() { - if (chains == null || chains.isEmpty()) { - return 0; - } - return chains.size() - chains.stream() - .filter(e -> Boolean.FALSE.equals(e.getResult())) - .collect(Collectors.toList()) - .size(); + return chains.size() - getFailedCounts(); } public List getChains() { diff --git a/src/test/java/com/github/liangbaika/validate/test/Tests.java b/src/test/java/com/github/liangbaika/validate/test/Tests.java index 6cf5a1a..3a8225e 100644 --- a/src/test/java/com/github/liangbaika/validate/test/Tests.java +++ b/src/test/java/com/github/liangbaika/validate/test/Tests.java @@ -16,16 +16,17 @@ public static void main(String[] args) { ValidateBuilder validateBuilder = ValidateBuilder.build(); int failedCounts = validateBuilder - .vali(ne, "测试不等", "测试不等") + .vali(ne, "3", "3","不能等于") .vali(Chinese, "测试中文") .vali(isBirthdaystr, "1992-12-09") .vali(isUrl, "https://baidu.com") .doCheck() .getFailedCounts(); System.out.println(failedCounts); - System.out.println(validateBuilder.isPassed()); System.out.println(validateBuilder.getSuccedCounts()); System.out.println(validateBuilder.getFailedMsgs()); + System.out.println(validateBuilder.isPassed()); + //重复使用 validateBuilder 先调用clear方法 int failedCounts2 = validateBuilder