@@ -20,7 +20,7 @@ class Validation
2020 protected $ aliases = [];
2121
2222 protected $ messageSeparator = ': ' ;
23-
23+
2424 protected $ validData = [];
2525 protected $ invalidData = [];
2626
@@ -72,7 +72,7 @@ protected function validateAttribute(Attribute $attribute)
7272 }
7373
7474 $ attributeKey = $ attribute ->getKey ();
75- $ rules = $ attribute ->getRules ();
75+ $ rules = $ attribute ->getRules ();
7676
7777 $ value = $ this ->getValue ($ attributeKey );
7878 $ isEmptyValue = $ this ->isEmptyValue ($ value );
@@ -92,7 +92,7 @@ protected function validateAttribute(Attribute $attribute)
9292 if ($ isEmptyValue AND $ this ->ruleIsOptional ($ attribute , $ ruleValidator )) {
9393 continue ;
9494 }
95-
95+
9696 if (!$ valid ) {
9797 $ isValid = false ;
9898 $ this ->addError ($ attribute , $ value , $ ruleValidator );
@@ -254,8 +254,8 @@ protected function isEmptyValue($value)
254254
255255 protected function ruleIsOptional (Attribute $ attribute , Rule $ rule )
256256 {
257- return false === $ attribute ->isRequired () AND
258- false === $ rule ->isImplicit () AND
257+ return false === $ attribute ->isRequired () AND
258+ false === $ rule ->isImplicit () AND
259259 false === $ rule instanceof Required;
260260 }
261261
@@ -288,14 +288,14 @@ protected function resolveMessage(Attribute $attribute, $value, Rule $validator)
288288 ];
289289
290290 if ($ primaryAttribute ) {
291- // insert primaryAttribute keys
291+ // insert primaryAttribute keys
292292 // $message_keys = [
293293 // $attributeKey.$this->messageSeparator.$ruleKey,
294294 // >> here [1] <<
295295 // $attributeKey,
296296 // >> and here [3] <<
297297 // $ruleKey
298- // ];
298+ // ];
299299 $ primaryAttributeKey = $ primaryAttribute ->getKey ();
300300 array_splice ($ message_keys , 1 , 0 , $ primaryAttributeKey .$ this ->messageSeparator .$ ruleKey );
301301 array_splice ($ message_keys , 3 , 0 , $ primaryAttributeKey );
@@ -359,7 +359,7 @@ protected function resolveRules($rules)
359359 foreach ($ rules as $ i => $ rule ) {
360360 if (empty ($ rule )) continue ;
361361 $ params = [];
362-
362+
363363 if (is_string ($ rule )) {
364364 list ($ rulename , $ params ) = $ this ->parseRule ($ rule );
365365 $ validator = call_user_func_array ($ validatorFactory , array_merge ([$ rulename ], $ params ));
@@ -446,7 +446,7 @@ protected function resolveInputAttributes(array $inputs)
446446 $ resolvedInputs = [];
447447 foreach ($ inputs as $ key => $ rules ) {
448448 $ exp = explode (': ' , $ key );
449-
449+
450450 if (count ($ exp ) > 1 ) {
451451 // set attribute alias
452452 $ this ->aliases [$ exp [0 ]] = $ exp [1 ];
@@ -457,16 +457,17 @@ protected function resolveInputAttributes(array $inputs)
457457
458458 return $ resolvedInputs ;
459459 }
460-
460+
461461 public function getValidatedData () {
462462 return array_merge ($ this ->validData , $ this ->invalidData );
463463 }
464464
465465 protected function setValidData (Attribute $ attribute , $ value )
466466 {
467467 $ key = $ attribute ->getKey ();
468- if ($ attribute ->isArrayAttribute ()) {
469- Helper::arraySet ($ this ->validData , $ key , $ value );
468+ if ($ attribute ->isArrayAttribute () || $ attribute ->isUsingDotNotation ()) {
469+ Helper::arraySet ($ this ->validData , $ key , $ value );
470+ Helper::arrayUnset ($ this ->invalidData , $ key );
470471 } else {
471472 $ this ->validData [$ key ] = $ value ;
472473 }
@@ -480,8 +481,9 @@ public function getValidData()
480481 protected function setInvalidData (Attribute $ attribute , $ value )
481482 {
482483 $ key = $ attribute ->getKey ();
483- if ($ attribute ->isArrayAttribute ()) {
484- Helper::arraySet ($ this ->invalidData , $ key , $ value );
484+ if ($ attribute ->isArrayAttribute () || $ attribute ->isUsingDotNotation ()) {
485+ Helper::arraySet ($ this ->invalidData , $ key , $ value );
486+ Helper::arrayUnset ($ this ->validData , $ key );
485487 } else {
486488 $ this ->invalidData [$ key ] = $ value ;
487489 }
0 commit comments