garydgregory commented on code in PR #395:
URL: https://github.com/apache/commons-validator/pull/395#discussion_r3408159692


##########
src/test/java/org/apache/commons/validator/routines/RegexValidatorTest.java:
##########
@@ -222,6 +222,19 @@ void testSingle() {
         checkArray("match one", new String[] { "ABC" }, new 
RegexValidator("^([A-Z]*)$").match("ABC"));
     }
 
+    /**
+     * Test that validate() is consistent with isValid() and match() when the 
only
+     * capturing group is optional and does not participate in the match. The 
value
+     * is valid, so validate() must not return null (which signals an invalid 
value).
+     */
+    @Test
+    void testValidateOptionalGroup() {
+        final RegexValidator validator = new RegexValidator("^(abc)?def$");
+        assertTrue(validator.isValid("def"), "isValid()");
+        checkArray("match()", new String[] { null }, validator.match("def"));
+        assertEquals("", validator.validate("def"), "validate()");

Review Comment:
   The additional noise in the failure messages are redundant with the method 
name.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to