File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,10 @@ protected function normalizeValue($value)
292
292
$ normalized = array ();
293
293
foreach ($ value as $ name => $ val ) {
294
294
if (isset ($ this ->children [$ name ])) {
295
- $ normalized [$ name ] = $ this ->children [$ name ]->normalize ($ val );
295
+ try {
296
+ $ normalized [$ name ] = $ this ->children [$ name ]->normalize ($ val );
297
+ } catch (UnsetKeyException $ e ) {
298
+ }
296
299
unset($ value [$ name ]);
297
300
} elseif (!$ this ->removeExtraKeys ) {
298
301
$ normalized [$ name ] = $ val ;
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ public function thenEmptyArray()
174
174
}
175
175
176
176
/**
177
- * Sets a closure marking the value as invalid at validation time.
177
+ * Sets a closure marking the value as invalid at processing time.
178
178
*
179
179
* if you want to add the value of the node in your message just use a %s placeholder.
180
180
*
@@ -192,7 +192,7 @@ public function thenInvalid($message)
192
192
}
193
193
194
194
/**
195
- * Sets a closure unsetting this key of the array at validation time.
195
+ * Sets a closure unsetting this key of the array at processing time.
196
196
*
197
197
* @return $this
198
198
*
Original file line number Diff line number Diff line change @@ -231,6 +231,25 @@ public function testNormalizeKeys()
231
231
$ this ->assertFalse ($ this ->getField ($ node , 'normalizeKeys ' ));
232
232
}
233
233
234
+ public function testUnsetChild ()
235
+ {
236
+ $ node = new ArrayNodeDefinition ('root ' );
237
+ $ node
238
+ ->children ()
239
+ ->scalarNode ('value ' )
240
+ ->beforeNormalization ()
241
+ ->ifTrue (function ($ value ) {
242
+ return empty ($ value );
243
+ })
244
+ ->thenUnset ()
245
+ ->end ()
246
+ ->end ()
247
+ ->end ()
248
+ ;
249
+
250
+ $ this ->assertSame (array (), $ node ->getNode ()->normalize (array ('value ' => null )));
251
+ }
252
+
234
253
public function testPrototypeVariable ()
235
254
{
236
255
$ node = new ArrayNodeDefinition ('root ' );
You can’t perform that action at this time.
0 commit comments