@@ -2,11 +2,11 @@ |
||
2 | 2 | namespace GraphQL\Type\Definition; |
3 | 3 | |
4 | 4 | class ValidateItemsError extends \Exception { |
5 | - public $path; |
|
6 | - public $error; |
|
7 | - function __construct($path, $error) { |
|
8 | - parent::__construct(); |
|
9 | - $this->path = $path; |
|
10 | - $this->error = $error; |
|
11 | - } |
|
5 | + public $path; |
|
6 | + public $error; |
|
7 | + function __construct($path, $error) { |
|
8 | + parent::__construct(); |
|
9 | + $this->path = $path; |
|
10 | + $this->error = $error; |
|
11 | + } |
|
12 | 12 | } |
13 | 13 | \ No newline at end of file |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | null, |
94 | 94 | [ |
95 | 95 | 'phoneNumbers' => [ |
96 | - [ |
|
97 | - '123-4567', |
|
98 | - 'xxx456-7890xxx' |
|
99 | - ] |
|
96 | + [ |
|
97 | + '123-4567', |
|
98 | + 'xxx456-7890xxx' |
|
99 | + ] |
|
100 | 100 | ], |
101 | 101 | ] |
102 | 102 | ); |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | 'phoneNumbers' => |
110 | 110 | [ |
111 | 111 | 'suberrors' => |
112 | - [ |
|
113 | - 'path' => [0,1], |
|
114 | - 'code' => 'invalidPhoneNumber', |
|
115 | - ] |
|
112 | + [ |
|
113 | + 'path' => [0,1], |
|
114 | + 'code' => 'invalidPhoneNumber', |
|
115 | + ] |
|
116 | 116 | ], |
117 | 117 | ], |
118 | 118 | 'result' => null, |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | static::assertFalse($res->data['setPhoneNumbers']['valid']); |
125 | 125 | } |
126 | 126 | |
127 | - public function testItemsValidationOnSelfFail() |
|
128 | - { |
|
129 | - $res = GraphQL::executeQuery( |
|
130 | - $this->schema, |
|
131 | - Utils::nowdoc(' |
|
127 | + public function testItemsValidationOnSelfFail() |
|
128 | + { |
|
129 | + $res = GraphQL::executeQuery( |
|
130 | + $this->schema, |
|
131 | + Utils::nowdoc(' |
|
132 | 132 | mutation SetPhoneNumbers( |
133 | 133 | $phoneNumbers: [[String]] |
134 | 134 | ) { |
@@ -148,34 +148,34 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | '), |
151 | - [], |
|
152 | - null, |
|
153 | - [ |
|
154 | - 'phoneNumbers' => [ |
|
155 | - ], |
|
156 | - ] |
|
157 | - ); |
|
158 | - |
|
159 | - static::assertEquals( |
|
160 | - array ( |
|
161 | - 'valid' => false, |
|
162 | - 'suberrors' => |
|
163 | - array ( |
|
164 | - 'phoneNumbers' => |
|
165 | - array ( |
|
166 | - 'code' => 'atLeastOneList', |
|
167 | - 'msg' => 'You must submit at least one list of numbers', |
|
168 | - 'suberrors' => NULL, |
|
169 | - ), |
|
170 | - ), |
|
171 | - 'result' => NULL, |
|
172 | - ), |
|
173 | - $res->data['setPhoneNumbers'] |
|
174 | - ); |
|
175 | - |
|
176 | - static::assertEmpty($res->errors); |
|
177 | - static::assertFalse($res->data['setPhoneNumbers']['valid']); |
|
178 | - } |
|
151 | + [], |
|
152 | + null, |
|
153 | + [ |
|
154 | + 'phoneNumbers' => [ |
|
155 | + ], |
|
156 | + ] |
|
157 | + ); |
|
158 | + |
|
159 | + static::assertEquals( |
|
160 | + array ( |
|
161 | + 'valid' => false, |
|
162 | + 'suberrors' => |
|
163 | + array ( |
|
164 | + 'phoneNumbers' => |
|
165 | + array ( |
|
166 | + 'code' => 'atLeastOneList', |
|
167 | + 'msg' => 'You must submit at least one list of numbers', |
|
168 | + 'suberrors' => NULL, |
|
169 | + ), |
|
170 | + ), |
|
171 | + 'result' => NULL, |
|
172 | + ), |
|
173 | + $res->data['setPhoneNumbers'] |
|
174 | + ); |
|
175 | + |
|
176 | + static::assertEmpty($res->errors); |
|
177 | + static::assertFalse($res->data['setPhoneNumbers']['valid']); |
|
178 | + } |
|
179 | 179 | |
180 | 180 | public function testListOfValidationFail() |
181 | 181 | { |
@@ -205,39 +205,39 @@ discard block |
||
205 | 205 | null, |
206 | 206 | [ |
207 | 207 | 'phoneNumbers' => [ |
208 | - [], |
|
209 | - [ |
|
210 | - '123-4567', |
|
211 | - 'xxx-7890', |
|
212 | - '321-1234' |
|
213 | - ] |
|
208 | + [], |
|
209 | + [ |
|
210 | + '123-4567', |
|
211 | + 'xxx-7890', |
|
212 | + '321-1234' |
|
213 | + ] |
|
214 | 214 | ], |
215 | 215 | ] |
216 | 216 | ); |
217 | 217 | |
218 | 218 | static::assertEmpty($res->errors); |
219 | 219 | static::assertEquals( |
220 | - array ( |
|
221 | - 'valid' => false, |
|
222 | - 'suberrors' => |
|
223 | - array ( |
|
224 | - 'phoneNumbers' => |
|
225 | - array ( |
|
226 | - 'code' => NULL, |
|
227 | - 'msg' => NULL, |
|
228 | - 'suberrors' => |
|
229 | - array ( |
|
230 | - 'path' => |
|
231 | - array ( |
|
232 | - 0 => 1, |
|
233 | - 1 => 1, |
|
234 | - ), |
|
235 | - 'code' => 'invalidPhoneNumber', |
|
236 | - ), |
|
237 | - ), |
|
238 | - ), |
|
239 | - 'result' => NULL, |
|
240 | - ), |
|
220 | + array ( |
|
221 | + 'valid' => false, |
|
222 | + 'suberrors' => |
|
223 | + array ( |
|
224 | + 'phoneNumbers' => |
|
225 | + array ( |
|
226 | + 'code' => NULL, |
|
227 | + 'msg' => NULL, |
|
228 | + 'suberrors' => |
|
229 | + array ( |
|
230 | + 'path' => |
|
231 | + array ( |
|
232 | + 0 => 1, |
|
233 | + 1 => 1, |
|
234 | + ), |
|
235 | + 'code' => 'invalidPhoneNumber', |
|
236 | + ), |
|
237 | + ), |
|
238 | + ), |
|
239 | + 'result' => NULL, |
|
240 | + ), |
|
241 | 241 | $res->data['setPhoneNumbers'] |
242 | 242 | ); |
243 | 243 |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | 'args' => [ |
100 | 100 | 'bookAttributes' => [ |
101 | 101 | 'type' => $this->bookAttributesInputType, |
102 | - 'errorCodes' => [ |
|
103 | - 'titleOrIdRequired' |
|
104 | - ], |
|
105 | - 'validate' => static function(?array $bookAttributes) { |
|
106 | - if(is_null($bookAttributes)) { |
|
107 | - return 0; |
|
108 | - } |
|
102 | + 'errorCodes' => [ |
|
103 | + 'titleOrIdRequired' |
|
104 | + ], |
|
105 | + 'validate' => static function(?array $bookAttributes) { |
|
106 | + if(is_null($bookAttributes)) { |
|
107 | + return 0; |
|
108 | + } |
|
109 | 109 | |
110 | - return (isset($bookAttributes['title']) || isset($bookAttributes['author'])) ? 0 : [ |
|
111 | - 'titleOrIdRequired', 'You must supply at least one of title or author' |
|
112 | - ]; |
|
113 | - } |
|
110 | + return (isset($bookAttributes['title']) || isset($bookAttributes['author'])) ? 0 : [ |
|
111 | + 'titleOrIdRequired', 'You must supply at least one of title or author' |
|
112 | + ]; |
|
113 | + } |
|
114 | 114 | ], |
115 | 115 | ], |
116 | 116 | 'resolve' => static function ($value, $args) : bool { |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | static::assertFalse($res->data['updateBook']['valid']); |
198 | 198 | } |
199 | 199 | |
200 | - public function testValidationInputObjectSelfFail() |
|
201 | - { |
|
202 | - $res = GraphQL::executeQuery( |
|
203 | - $this->schema, |
|
204 | - Utils::nowdoc(' |
|
200 | + public function testValidationInputObjectSelfFail() |
|
201 | + { |
|
202 | + $res = GraphQL::executeQuery( |
|
203 | + $this->schema, |
|
204 | + Utils::nowdoc(' |
|
205 | 205 | mutation UpdateBook( |
206 | 206 | $bookAttributes: BookAttributes |
207 | 207 | ) { |
@@ -229,35 +229,35 @@ discard block |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | '), |
232 | - [], |
|
233 | - null, |
|
234 | - [ |
|
235 | - 'bookAttributes' => [ |
|
236 | - 'title' => null, |
|
237 | - 'author' => null, |
|
238 | - ], |
|
239 | - ] |
|
240 | - ); |
|
232 | + [], |
|
233 | + null, |
|
234 | + [ |
|
235 | + 'bookAttributes' => [ |
|
236 | + 'title' => null, |
|
237 | + 'author' => null, |
|
238 | + ], |
|
239 | + ] |
|
240 | + ); |
|
241 | 241 | |
242 | - static::assertEquals( |
|
243 | - array ( |
|
244 | - 'valid' => false, |
|
245 | - 'suberrors' => |
|
246 | - array ( |
|
247 | - 'bookAttributes' => |
|
248 | - array ( |
|
249 | - 'code' => 'titleOrIdRequired', |
|
250 | - 'msg' => 'You must supply at least one of title or author', |
|
251 | - 'suberrors' => NULL, |
|
252 | - ), |
|
253 | - ), |
|
254 | - 'result' => NULL, |
|
255 | - ), |
|
256 | - $res->data['updateBook'] |
|
257 | - ); |
|
242 | + static::assertEquals( |
|
243 | + array ( |
|
244 | + 'valid' => false, |
|
245 | + 'suberrors' => |
|
246 | + array ( |
|
247 | + 'bookAttributes' => |
|
248 | + array ( |
|
249 | + 'code' => 'titleOrIdRequired', |
|
250 | + 'msg' => 'You must supply at least one of title or author', |
|
251 | + 'suberrors' => NULL, |
|
252 | + ), |
|
253 | + ), |
|
254 | + 'result' => NULL, |
|
255 | + ), |
|
256 | + $res->data['updateBook'] |
|
257 | + ); |
|
258 | 258 | |
259 | - static::assertFalse($res->data['updateBook']['valid']); |
|
260 | - } |
|
259 | + static::assertFalse($res->data['updateBook']['valid']); |
|
260 | + } |
|
261 | 261 | |
262 | 262 | public function testValidationSuccess() |
263 | 263 | { |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | |
352 | 352 | static::assertEmpty($res->errors); |
353 | 353 | static::assertEquals( |
354 | - array ( |
|
355 | - 'valid' => true, |
|
356 | - 'suberrors' => NULL, |
|
357 | - 'result' => true, |
|
358 | - ), |
|
354 | + array ( |
|
355 | + 'valid' => true, |
|
356 | + 'suberrors' => NULL, |
|
357 | + 'result' => true, |
|
358 | + ), |
|
359 | 359 | $res->data['updateBook'] |
360 | 360 | ); |
361 | 361 |
@@ -33,11 +33,11 @@ |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function testNoType() { |
36 | - $this->expectExceptionMessage("You must specify a type for your field"); |
|
37 | - UserErrorsType::create([ |
|
38 | - 'validate' => static function ($value) { |
|
39 | - } |
|
40 | - ], ['upsertSku']); |
|
36 | + $this->expectExceptionMessage("You must specify a type for your field"); |
|
37 | + UserErrorsType::create([ |
|
38 | + 'validate' => static function ($value) { |
|
39 | + } |
|
40 | + ], ['upsertSku']); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function testValidationWithNoErrorCodes() |
@@ -23,40 +23,40 @@ |
||
23 | 23 | { |
24 | 24 | $finalFields = $config['fields'] ?? []; |
25 | 25 | |
26 | - if (!isset($config['type'])) { |
|
27 | - throw new \Exception('You must specify a type for your field'); |
|
28 | - } |
|
26 | + if (!isset($config['type'])) { |
|
27 | + throw new \Exception('You must specify a type for your field'); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.'); |
31 | 31 | |
32 | 32 | if (isset($config['errorCodes'])) { |
33 | - if(isset($config['validate'])) { |
|
34 | - /** code property */ |
|
35 | - $finalFields['code'] = [ |
|
36 | - 'type' => $this->_set(new EnumType([ |
|
37 | - 'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode', |
|
38 | - 'description' => 'Error code', |
|
39 | - 'values' => $config['errorCodes'], |
|
40 | - ]), $config), |
|
41 | - 'description' => 'An error code', |
|
42 | - 'resolve' => static function ($value) { |
|
43 | - return $value['error'][0] ?? null; |
|
44 | - }, |
|
45 | - ]; |
|
46 | - |
|
47 | - /** |
|
48 | - * msg property |
|
49 | - */ |
|
50 | - $finalFields['msg'] = [ |
|
51 | - 'type' => Type::string(), |
|
52 | - 'description' => 'A natural language description of the issue', |
|
53 | - 'resolve' => static function ($value) { |
|
54 | - return $value['error'][1] ?? null; |
|
55 | - }, |
|
56 | - ]; |
|
57 | - } else { |
|
58 | - throw new \Exception("If you specify errorCodes, you must also provide a validate callback"); |
|
59 | - } |
|
33 | + if(isset($config['validate'])) { |
|
34 | + /** code property */ |
|
35 | + $finalFields['code'] = [ |
|
36 | + 'type' => $this->_set(new EnumType([ |
|
37 | + 'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode', |
|
38 | + 'description' => 'Error code', |
|
39 | + 'values' => $config['errorCodes'], |
|
40 | + ]), $config), |
|
41 | + 'description' => 'An error code', |
|
42 | + 'resolve' => static function ($value) { |
|
43 | + return $value['error'][0] ?? null; |
|
44 | + }, |
|
45 | + ]; |
|
46 | + |
|
47 | + /** |
|
48 | + * msg property |
|
49 | + */ |
|
50 | + $finalFields['msg'] = [ |
|
51 | + 'type' => Type::string(), |
|
52 | + 'description' => 'A natural language description of the issue', |
|
53 | + 'resolve' => static function ($value) { |
|
54 | + return $value['error'][1] ?? null; |
|
55 | + }, |
|
56 | + ]; |
|
57 | + } else { |
|
58 | + throw new \Exception("If you specify errorCodes, you must also provide a validate callback"); |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $type = $config['type']; |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | ]); |
78 | 78 | } |
79 | 79 | |
80 | - protected function _isAssoc(array $arr) |
|
81 | - { |
|
82 | - if (array() === $arr) return false; |
|
83 | - return array_keys($arr) !== range(0, count($arr) - 1); |
|
84 | - } |
|
80 | + protected function _isAssoc(array $arr) |
|
81 | + { |
|
82 | + if (array() === $arr) return false; |
|
83 | + return array_keys($arr) !== range(0, count($arr) - 1); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | protected function _validateItems($value, array $path, callable $validate) { |
87 | 87 | foreach ($value as $idx => $subValue) { |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | |
150 | 150 | $fields = $type->getFields(); |
151 | 151 | if(is_array($value)) { |
152 | - foreach ($value as $key => $subValue) { |
|
153 | - $config = $fields[$key]->config; |
|
154 | - $res['suberrors'][$key] = $this->_validate($config, $subValue); |
|
155 | - } |
|
156 | - $res['suberrors'] = array_filter($res['suberrors'] ?? []); |
|
152 | + foreach ($value as $key => $subValue) { |
|
153 | + $config = $fields[$key]->config; |
|
154 | + $res['suberrors'][$key] = $this->_validate($config, $subValue); |
|
155 | + } |
|
156 | + $res['suberrors'] = array_filter($res['suberrors'] ?? []); |
|
157 | 157 | } |
158 | 158 | break; |
159 | 159 |
@@ -118,21 +118,21 @@ discard block |
||
118 | 118 | public function testListOfInputObjectWithValidationOnSelf() |
119 | 119 | { |
120 | 120 | $type = new UserErrorsType([ |
121 | - 'validate' => static function(array $authors) { |
|
122 | - if(count($authors) < 1) { |
|
123 | - return ['atLeastOneAuthorRequired', "You must submit at least one author"]; |
|
124 | - } |
|
125 | - }, |
|
126 | - 'errorCodes' => ['atLeastOneBookRequired'], |
|
127 | - 'type' => Type::listOf(new InputObjectType([ |
|
121 | + 'validate' => static function(array $authors) { |
|
122 | + if(count($authors) < 1) { |
|
123 | + return ['atLeastOneAuthorRequired', "You must submit at least one author"]; |
|
124 | + } |
|
125 | + }, |
|
126 | + 'errorCodes' => ['atLeastOneBookRequired'], |
|
127 | + 'type' => Type::listOf(new InputObjectType([ |
|
128 | 128 | 'name'=> 'Author', |
129 | 129 | 'fields' => [ |
130 | 130 | 'firstName' => [ |
131 | 131 | 'type' => Type::string(), |
132 | 132 | ], |
133 | - 'lastName' => [ |
|
134 | - 'type' => Type::string(), |
|
135 | - ], |
|
133 | + 'lastName' => [ |
|
134 | + 'type' => Type::string(), |
|
135 | + ], |
|
136 | 136 | ], |
137 | 137 | ])) |
138 | 138 | ], ['authorList']); |
@@ -159,32 +159,32 @@ discard block |
||
159 | 159 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
160 | 160 | } |
161 | 161 | |
162 | - public function testListOfInputObjectWithValidationOnWrappedSelf() |
|
163 | - { |
|
164 | - $type = new UserErrorsType([ |
|
165 | - 'suberrorCodes' => ['firstNameOrLastNameRequired'], |
|
166 | - 'validateItem' => static function(array $author) { |
|
167 | - if(!isset($author['firstName']) && !isset($author['lastName'])) { |
|
168 | - return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"]; |
|
169 | - } |
|
170 | - }, |
|
171 | - 'type' => Type::listOf(new InputObjectType([ |
|
172 | - 'name'=> 'Author', |
|
173 | - 'fields' => [ |
|
174 | - 'firstName' => [ |
|
175 | - 'type' => Type::string(), |
|
176 | - 'validate' => function(string $name) { |
|
177 | - return $name ? 0 : 1; |
|
178 | - } |
|
179 | - ], |
|
180 | - 'lastName' => [ |
|
181 | - 'type' => Type::string(), |
|
182 | - ], |
|
183 | - ], |
|
184 | - ])) |
|
185 | - ], ['authorList']); |
|
186 | - |
|
187 | - self::assertEquals(Utils::nowdoc(' |
|
162 | + public function testListOfInputObjectWithValidationOnWrappedSelf() |
|
163 | + { |
|
164 | + $type = new UserErrorsType([ |
|
165 | + 'suberrorCodes' => ['firstNameOrLastNameRequired'], |
|
166 | + 'validateItem' => static function(array $author) { |
|
167 | + if(!isset($author['firstName']) && !isset($author['lastName'])) { |
|
168 | + return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"]; |
|
169 | + } |
|
170 | + }, |
|
171 | + 'type' => Type::listOf(new InputObjectType([ |
|
172 | + 'name'=> 'Author', |
|
173 | + 'fields' => [ |
|
174 | + 'firstName' => [ |
|
175 | + 'type' => Type::string(), |
|
176 | + 'validate' => function(string $name) { |
|
177 | + return $name ? 0 : 1; |
|
178 | + } |
|
179 | + ], |
|
180 | + 'lastName' => [ |
|
181 | + 'type' => Type::string(), |
|
182 | + ], |
|
183 | + ], |
|
184 | + ])) |
|
185 | + ], ['authorList']); |
|
186 | + |
|
187 | + self::assertEquals(Utils::nowdoc(' |
|
188 | 188 | schema { |
189 | 189 | query: AuthorListError |
190 | 190 | } |
@@ -231,5 +231,5 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
234 | - } |
|
234 | + } |
|
235 | 235 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | public function testFieldsWithErrorCodesButNoValidate() |
47 | 47 | { |
48 | - $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback"); |
|
48 | + $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback"); |
|
49 | 49 | |
50 | - new UserErrorsType([ |
|
50 | + new UserErrorsType([ |
|
51 | 51 | 'type' => new InputObjectType([ |
52 | 52 | 'name' => 'bookInput', |
53 | 53 | 'fields' => [ |
@@ -61,25 +61,25 @@ discard block |
||
61 | 61 | ], ['updateBook']); |
62 | 62 | } |
63 | 63 | |
64 | - public function testFieldsWithValidate() |
|
65 | - { |
|
66 | - $type = new UserErrorsType([ |
|
67 | - 'type' => new InputObjectType([ |
|
68 | - 'name' => 'bookInput', |
|
69 | - 'fields' => [ |
|
70 | - 'authorId' => [ |
|
71 | - 'errorCodes' => ['unknownAuthor'], |
|
72 | - 'validate' => static function(int $authorId) { |
|
73 | - return $authorId ? 0 : 1; |
|
74 | - }, |
|
75 | - 'type' => Type::id(), |
|
76 | - 'description' => 'An author Id', |
|
77 | - ], |
|
78 | - ], |
|
79 | - ]) |
|
80 | - ], ['updateBook']); |
|
64 | + public function testFieldsWithValidate() |
|
65 | + { |
|
66 | + $type = new UserErrorsType([ |
|
67 | + 'type' => new InputObjectType([ |
|
68 | + 'name' => 'bookInput', |
|
69 | + 'fields' => [ |
|
70 | + 'authorId' => [ |
|
71 | + 'errorCodes' => ['unknownAuthor'], |
|
72 | + 'validate' => static function(int $authorId) { |
|
73 | + return $authorId ? 0 : 1; |
|
74 | + }, |
|
75 | + 'type' => Type::id(), |
|
76 | + 'description' => 'An author Id', |
|
77 | + ], |
|
78 | + ], |
|
79 | + ]) |
|
80 | + ], ['updateBook']); |
|
81 | 81 | |
82 | - self::assertEquals(Utils::nowdoc(' |
|
82 | + self::assertEquals(Utils::nowdoc(' |
|
83 | 83 | schema { |
84 | 84 | query: UpdateBookError |
85 | 85 | } |
@@ -111,5 +111,5 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
114 | - } |
|
114 | + } |
|
115 | 115 | } |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | 'args' => [ |
101 | 101 | 'bookAttributes' => [ |
102 | 102 | 'type' => Type::listOf($this->bookAttributesInputType), |
103 | - 'validate' => static function($var) { |
|
104 | - return $var ? 0: 1; |
|
105 | - }, |
|
106 | - 'validateItem' => static function($book) { |
|
107 | - $res = isset($book['author']) || isset($book['title']) ? 0: 1; |
|
108 | - return $res; |
|
109 | - } |
|
103 | + 'validate' => static function($var) { |
|
104 | + return $var ? 0: 1; |
|
105 | + }, |
|
106 | + 'validateItem' => static function($book) { |
|
107 | + $res = isset($book['author']) || isset($book['title']) ? 0: 1; |
|
108 | + return $res; |
|
109 | + } |
|
110 | 110 | ], |
111 | 111 | ], |
112 | 112 | 'resolve' => static function ($value) : bool { |
@@ -162,30 +162,30 @@ discard block |
||
162 | 162 | ] |
163 | 163 | ); |
164 | 164 | |
165 | - static::assertEmpty($res->errors); |
|
165 | + static::assertEmpty($res->errors); |
|
166 | 166 | |
167 | 167 | static::assertEquals( |
168 | - array ( |
|
169 | - 'valid' => false, |
|
170 | - 'result' => NULL, |
|
171 | - 'suberrors' => |
|
172 | - array ( |
|
173 | - 'bookAttributes' => |
|
174 | - array ( |
|
175 | - 'code' => NULL, |
|
176 | - 'msg' => NULL, |
|
177 | - 'suberrors' => |
|
178 | - array ( |
|
179 | - 'code' => 1, |
|
180 | - 'msg' => '', |
|
181 | - 'path' => |
|
182 | - array ( |
|
183 | - 0 => 1, |
|
184 | - ), |
|
185 | - ), |
|
186 | - ), |
|
187 | - ), |
|
188 | - ), |
|
168 | + array ( |
|
169 | + 'valid' => false, |
|
170 | + 'result' => NULL, |
|
171 | + 'suberrors' => |
|
172 | + array ( |
|
173 | + 'bookAttributes' => |
|
174 | + array ( |
|
175 | + 'code' => NULL, |
|
176 | + 'msg' => NULL, |
|
177 | + 'suberrors' => |
|
178 | + array ( |
|
179 | + 'code' => 1, |
|
180 | + 'msg' => '', |
|
181 | + 'path' => |
|
182 | + array ( |
|
183 | + 0 => 1, |
|
184 | + ), |
|
185 | + ), |
|
186 | + ), |
|
187 | + ), |
|
188 | + ), |
|
189 | 189 | $res->data['updateBooks'] |
190 | 190 | ); |
191 | 191 |