[Validator] Property paths starting with 0 are broken.
This commit is contained in:
parent
1ea4612d7e
commit
b3db07f5f2
@ -30,6 +30,7 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('', 'bar', 'bar', 'It returns the subPath if basePath is empty'),
|
array('', 'bar', 'bar', 'It returns the subPath if basePath is empty'),
|
||||||
array('foo', 'bar', 'foo.bar', 'It append the subPath to the basePath'),
|
array('foo', 'bar', 'foo.bar', 'It append the subPath to the basePath'),
|
||||||
array('foo', '[bar]', 'foo[bar]', 'It does not include the dot separator if subPath uses the array notation'),
|
array('foo', '[bar]', 'foo[bar]', 'It does not include the dot separator if subPath uses the array notation'),
|
||||||
|
array('0', 'bar', '0.bar', 'Leading zeros are kept.'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ namespace Symfony\Component\Validator\Util;
|
|||||||
* For more extensive functionality, use Symfony's PropertyAccess component.
|
* For more extensive functionality, use Symfony's PropertyAccess component.
|
||||||
*
|
*
|
||||||
* @since 2.5
|
* @since 2.5
|
||||||
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
class PropertyPath
|
class PropertyPath
|
||||||
@ -42,7 +43,7 @@ class PropertyPath
|
|||||||
return $basePath.$subPath;
|
return $basePath.$subPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $basePath ? $basePath.'.'.$subPath : $subPath;
|
return '' !== (string) $basePath ? $basePath.'.'.$subPath : $subPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $basePath;
|
return $basePath;
|
||||||
|
@ -34,6 +34,7 @@ use Symfony\Component\Validator\Util\PropertyPath;
|
|||||||
* Recursive implementation of {@link ContextualValidatorInterface}.
|
* Recursive implementation of {@link ContextualValidatorInterface}.
|
||||||
*
|
*
|
||||||
* @since 2.5
|
* @since 2.5
|
||||||
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
class RecursiveContextualValidator implements ContextualValidatorInterface
|
class RecursiveContextualValidator implements ContextualValidatorInterface
|
||||||
@ -526,7 +527,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
|
|||||||
} elseif ($metadata->isGroupSequenceProvider()) {
|
} elseif ($metadata->isGroupSequenceProvider()) {
|
||||||
// The group sequence is dynamically obtained from the validated
|
// The group sequence is dynamically obtained from the validated
|
||||||
// object
|
// object
|
||||||
/** @var \Symfony\Component\Validator\GroupSequenceProviderInterface $object */
|
/* @var \Symfony\Component\Validator\GroupSequenceProviderInterface $object */
|
||||||
$group = $object->getGroupSequence();
|
$group = $object->getGroupSequence();
|
||||||
$defaultOverridden = true;
|
$defaultOverridden = true;
|
||||||
|
|
||||||
@ -590,9 +591,7 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
|
|||||||
$object,
|
$object,
|
||||||
$cacheKey.':'.$propertyName,
|
$cacheKey.':'.$propertyName,
|
||||||
$propertyMetadata,
|
$propertyMetadata,
|
||||||
$propertyPath
|
PropertyPath::append($propertyPath, $propertyName),
|
||||||
? $propertyPath.'.'.$propertyName
|
|
||||||
: $propertyName,
|
|
||||||
$groups,
|
$groups,
|
||||||
$cascadedGroups,
|
$cascadedGroups,
|
||||||
TraversalStrategy::IMPLICIT,
|
TraversalStrategy::IMPLICIT,
|
||||||
|
Reference in New Issue
Block a user