File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
src/test/java/test/org/javawebstack/validator Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 44import org .javawebstack .validator .Rule ;
55import org .javawebstack .validator .ValidationContext ;
66import org .javawebstack .validator .Validator ;
7+ import org .javawebstack .validator .rule .RequiredRule ;
78import org .junit .jupiter .api .Test ;
89
910import static org .junit .jupiter .api .Assertions .assertFalse ;
@@ -21,6 +22,17 @@ public void testSimpleRequiredRule() {
2122 assertTrue (validator .validate (new ValidationContext (), new AbstractMapper ().toAbstract (test )).isValid ());
2223 }
2324
25+ @ Test
26+ public void testEmptyStringOption () {
27+ Validator validator = Validator .getValidator (TestObject1 .class );
28+ TestObject1 test = new TestObject1 ();
29+ test .name = "" ;
30+ assertFalse (validator .validate (new ValidationContext (), new AbstractMapper ().toAbstract (test )).isValid ());
31+ test .name = "Test" ;
32+ test .password = "" ;
33+ assertTrue (validator .validate (new ValidationContext (), new AbstractMapper ().toAbstract (test )).isValid ());
34+ }
35+
2436 @ Test
2537 public void testInnerRequiredRule () {
2638 Validator validator = Validator .getValidator (TestObject2 .class );
@@ -36,10 +48,11 @@ public void testInnerRequiredRule() {
3648 assertTrue (validator .validate (new ValidationContext (), new AbstractMapper ().toAbstract (test )).isValid ());
3749 }
3850
51+
3952 private static class TestObject1 {
4053 @ Rule ("required" )
4154 String name ;
42- @ Rule ( "req" )
55+ @ RequiredRule ( allowEmptyStrings = true )
4356 String password ;
4457 }
4558
You can’t perform that action at this time.
0 commit comments