File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -118,11 +118,12 @@ No valid results for oneOf {
118
118
} at #->properties:root->patternProperties[^[a-zA-Z0-9_]+$]:zoo
119
119
```
120
120
121
- For ambiguous schemas defined with ` oneOf ` /` anyOf ` message is indented multi-line.
121
+ For ambiguous schemas defined with ` oneOf ` /` anyOf ` message is indented multi-line string .
122
122
123
- Processing path is a combination of schema and data pointers. You can use ` PointerUtil ` to extract schema/data pointer.
123
+ Processing path is a combination of schema and data pointers. You can use ` InvalidValue->getSchemaPointer() `
124
+ and ` InvalidValue->getDataPointer() ` to extract schema/data pointer.
124
125
125
- You can build ` Error ` tree from exception using ` InvalidValue:: inspect($exception ) ` .
126
+ You can build error tree using ` InvalidValue-> inspect() ` .
126
127
127
128
### PHP structured classes with validation
128
129
Original file line number Diff line number Diff line change @@ -24,18 +24,29 @@ public function addPath($path)
24
24
const NOT_IMPLEMENTED = 2 ;
25
25
26
26
27
- public static function inspect (InvalidValue $ invalidValue )
27
+ public function inspect ()
28
28
{
29
29
$ error = new Error ();
30
- $ error ->error = $ invalidValue ->error ;
31
- $ error ->processingPath = $ invalidValue ->path ;
30
+ $ error ->error = $ this ->error ;
31
+ $ error ->processingPath = $ this ->path ;
32
32
$ error ->dataPointer = PointerUtil::getDataPointer ($ error ->processingPath );
33
33
$ error ->schemaPointers = PointerUtil::getSchemaPointers ($ error ->processingPath );
34
- if ($ invalidValue instanceof LogicException) {
35
- foreach ($ invalidValue ->subErrors as $ nestedError ) {
36
- $ error ->subErrors [] = self :: inspect ($ nestedError );
34
+ if ($ this instanceof LogicException) {
35
+ foreach ($ this ->subErrors as $ subError ) {
36
+ $ error ->subErrors [] = $ subError -> inspect ();
37
37
}
38
38
}
39
39
return $ error ;
40
40
}
41
+
42
+ public function getSchemaPointer ()
43
+ {
44
+ return PointerUtil::getSchemaPointer ($ this ->path );
45
+ }
46
+
47
+ public function getDataPointer ()
48
+ {
49
+ return PointerUtil::getDataPointer ($ this ->path );
50
+ }
51
+
41
52
}
Original file line number Diff line number Diff line change @@ -169,8 +169,10 @@ public function testErrorMessage()
169
169
$ this ->fail ('Exception expected ' );
170
170
} catch (InvalidValue $ exception ) {
171
171
$ this ->assertSame ($ expectedException , $ exception ->getMessage ());
172
- $ error = InvalidValue:: inspect ( $ exception );
172
+ $ error = $ exception-> inspect ( );
173
173
$ this ->assertSame ($ errorInspected , print_r ($ error , 1 ));
174
+ $ this ->assertSame ('/properties/root/patternProperties/^[a-zA-Z0-9_]+$ ' , $ exception ->getSchemaPointer ());
175
+ $ this ->assertSame ('/root/zoo ' , $ exception ->getDataPointer ());
174
176
}
175
177
}
176
178
You can’t perform that action at this time.
0 commit comments