Skip to content

Commit 992a0bc

Browse files
MariusRumpfChristian Blank
authored andcommitted
Add example of nesting to README (#18)
This adds a example of how to use nesting for structure checks to the README.
1 parent b50117d commit 992a0bc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ $requirement = new ListType(
2424
'foo' => new StringType(),
2525
'bar' => new IntType(),
2626
'buzz' => new AnyType(),
27-
'foobar' => new NullableType(new StringType())
27+
'foobar' => new NullableType(new StringType()),
28+
'nested' => new ObjectType([
29+
'foobar' => new StringType(),
30+
]),
2831
])
2932
);
3033
```
@@ -35,16 +38,25 @@ $data = [
3538
'foo' => 'foe',
3639
'bar' => 'baz',
3740
'buzz' => 'foe',
38-
'foobar' => null
41+
'foobar' => null,
42+
'nested' => [
43+
'foobar' => 'buzz',
44+
],
3945
], [
4046
'foo' => 'foe',
4147
'bar' => 7,
4248
'buzz' => 'foe',
4349
'foobar' => 'baz',
50+
'nested' => [
51+
'foobar' => 'bozz',
52+
],
4453
], [
4554
'foo' => [],
4655
'bar' => 9.1,
4756
'foobar' => 'baz',
57+
'nested' => [
58+
'foobar' => 'bazz',
59+
],
4860
],
4961
];
5062
```
@@ -81,4 +93,4 @@ Additionally you can implement the `TypeInterface` and use your own type impleme
8193

8294
Checks are special types which can be used to add more rules to a field. So you can check
8395
the length of a string, the count of elements in an array or determine if
84-
a numeric value is in a given range.
96+
a numeric value is in a given range.

0 commit comments

Comments
 (0)