Skip to content

Commit 5e52f92

Browse files
committed
add
1 parent 9e150ad commit 5e52f92

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
package hexlet.code;
22

3-
import hexlet.code.schemas.StringSchema;
3+
import hexlet.code.schemas.BaseSchema;
4+
5+
import java.util.HashMap;
6+
import java.util.Map;
47

58
public class App {
69
public static void main(String[] args) {
710
Validator v = new Validator();
8-
StringSchema schema = v.string();
911

10-
System.out.println(schema.isValid("")); // true
11-
System.out.println(schema.isValid(null)); // true
12+
MapSchema schema = v.map();
13+
14+
Map<String, BaseSchema<?>> schemas = new HashMap<>();
15+
schemas.put("name", v.string().required());
16+
schemas.put("age", v.number().positive());
1217

13-
schema.required();
18+
schema.shape(schemas);
1419

15-
System.out.println(schema.isValid(null)); // false
16-
System.out.println(schema.isValid("")); // false
17-
System.out.println(schema.isValid("what does the fox say")); // true
18-
System.out.println(schema.isValid("hexlet")); // true
20+
Map<String, Object> human1 = new HashMap<>();
21+
human1.put("name", "Alice");
22+
human1.put("age", 25);
1923

20-
schema.contains("wh").isValid("what does the fox say"); // true
21-
schema.contains("what").isValid("what does the fox say"); // true
22-
schema.contains("whatthe").isValid("what does the fox say"); // false
24+
System.out.println(schema.isValid(human1));
2325

24-
System.out.println(schema.isValid("what does the fox say")); // false
26+
Map<String, Object> human2 = new HashMap<>();
27+
human2.put("name", "Bob");
28+
human2.put("age", -5);
2529

26-
StringSchema schema1 = v.string();
27-
System.out.println(schema1.minLength(10).minLength(4).isValid("Hexlet")); // true
30+
System.out.println(schema.isValid(human2));
2831
}
2932
}

0 commit comments

Comments
 (0)