Skip to content

Commit 6636005

Browse files
committed
add
1 parent e909cc9 commit 6636005

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

app/src/main/java/hexlet/code/schemas/MapSchema.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ public boolean isValid(Object value) {
2828
return false;
2929
}
3030
Map<?, ?> map = (Map<?, ?>) value;
31+
3132
if (requiredSize != -1 && map.size() != requiredSize) {
3233
return false;
3334
}
35+
3436
if (schemas != null) {
3537
for (Map.Entry<String, BaseSchema<?, ?>> entry : schemas.entrySet()) {
3638
String key = entry.getKey();
@@ -40,6 +42,7 @@ public boolean isValid(Object value) {
4042
}
4143
}
4244
}
45+
4346
return true;
4447
}
4548
}

app/src/main/java/hexlet/code/schemas/NumberSchema.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ public NumberSchema range(int min, int max) {
1818

1919
@Override
2020
public boolean isValid(Object value) {
21+
2122
if (isRequired && value == null) {
2223
return false;
2324
}
25+
2426
if (value == null) {
2527
return true;
2628
}
29+
2730
if (!(value instanceof Integer)) {
2831
return false;
2932
}

app/src/main/java/hexlet/code/schemas/StringSchema.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ public StringSchema contains(String substring) {
1616

1717
@Override
1818
public boolean isValid(Object value) {
19+
1920
if (isRequired && value == null) {
2021
return false;
2122
}
23+
2224
if (value == null) {
2325
return true;
2426
}
27+
2528
if (!(value instanceof String)) {
2629
return false;
2730
}

0 commit comments

Comments
 (0)