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 @@ -288,7 +288,10 @@ protected function normalizeValue($value)
288
288
$ normalized = array ();
289
289
foreach ($ value as $ name => $ val ) {
290
290
if (isset ($ this ->children [$ name ])) {
291
- $ normalized [$ name ] = $ this ->children [$ name ]->normalize ($ val );
291
+ try {
292
+ $ normalized [$ name ] = $ this ->children [$ name ]->normalize ($ val );
293
+ } catch (UnsetKeyException $ e ) {
294
+ }
292
295
unset($ value [$ name ]);
293
296
} elseif (!$ this ->removeExtraKeys ) {
294
297
$ normalized [$ name ] = $ val ;
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ public function thenEmptyArray()
149
149
}
150
150
151
151
/**
152
- * Sets a closure marking the value as invalid at validation time.
152
+ * Sets a closure marking the value as invalid at processing time.
153
153
*
154
154
* if you want to add the value of the node in your message just use a %s placeholder.
155
155
*
@@ -167,7 +167,7 @@ public function thenInvalid($message)
167
167
}
168
168
169
169
/**
170
- * Sets a closure unsetting this key of the array at validation time.
170
+ * Sets a closure unsetting this key of the array at processing time.
171
171
*
172
172
* @return $this
173
173
*
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 getEnableableNodeFixtures ()
235
254
{
236
255
return array (
You can’t perform that action at this time.
0 commit comments