File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
main/java/hexlet/code/schemas Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,7 @@ public NumberSchema required() {
1414 }
1515
1616 public NumberSchema positive () {
17- Predicate <Integer > positive = e -> {
18- if (e == 0 ) {
19- return false ;
20- } else {
21- return e > 0 ;
22- }
23- };
17+ Predicate <Integer > positive = e -> e > 0 ;
2418 addCheck (numberIsPositive , positive );
2519 return this ;
2620 }
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ public void testRange() {
2828 NumberSchema numberSchema = new NumberSchema ().range (10 , 20 );
2929
3030 assertTrue (numberSchema .isValid (15 ));
31+ assertTrue (numberSchema .isValid (10 ));
32+ assertTrue (numberSchema .isValid (20 ));
3133 assertFalse (numberSchema .isValid (5 ));
3234 assertFalse (numberSchema .isValid (25 ));
3335 }
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ public void testRequired() {
1212
1313 assertTrue (stringSchema .isValid ("test" ));
1414 assertFalse (stringSchema .isValid ("" ));
15- assertFalse (stringSchema .isValid (null ));
1615 }
1716
1817 @ Test
@@ -43,4 +42,13 @@ public void testCombination() {
4342 assertFalse (stringSchema .isValid ("test" ));
4443 assertFalse (stringSchema .isValid (null ));
4544 }
45+
46+ @ Test
47+ public void testWithoutRequired () {
48+ StringSchema stringSchema = new StringSchema ();
49+
50+ assertTrue (stringSchema .isValid (null ));
51+ assertTrue (stringSchema .isValid ("" ));
52+ assertTrue (stringSchema .isValid ("test" ));
53+ }
4654}
You can’t perform that action at this time.
0 commit comments