Skip to content

Commit bb5028e

Browse files
add method shape in MapSchema.java
1 parent 32c8b4c commit bb5028e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,17 @@ MapSchema sizeof(int limitSize) {
1515
return this;
1616
}
1717

18-
//public MapSchema shape()
18+
MapSchema shape(Map<String, BaseSchema> schemas) {
19+
addValidation(
20+
"shape",
21+
map -> {
22+
return schemas.entrySet()
23+
.stream()
24+
.allMatch(e ->
25+
e.getValue().isValid((map.get(e.getKey())))
26+
);
27+
}
28+
);
29+
return this;
30+
}
1931
}

0 commit comments

Comments
 (0)