public function Validator::validateProperty in Plug 7
Throws
ValidatorException If the metadata for the value does not support properties.
Overrides ValidatorInterface::validateProperty
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Validator.php, line 111
Class
- Validator
- Default implementation of {@link ValidatorInterface}.
Namespace
Symfony\Component\ValidatorCode
public function validateProperty($containingValue, $property, $groups = null) {
$visitor = $this
->createVisitor($containingValue);
$metadata = $this->metadataFactory
->getMetadataFor($containingValue);
if (!$metadata instanceof PropertyMetadataContainerInterface) {
$valueAsString = is_scalar($containingValue) ? '"' . $containingValue . '"' : 'the value of type ' . gettype($containingValue);
throw new ValidatorException(sprintf('The metadata for %s does not support properties.', $valueAsString));
}
foreach ($this
->resolveGroups($groups) as $group) {
if (!$metadata
->hasPropertyMetadata($property)) {
continue;
}
foreach ($metadata
->getPropertyMetadata($property) as $propMeta) {
$propMeta
->accept($visitor, $propMeta
->getPropertyValue($containingValue), $group, $property);
}
}
return $visitor
->getViolations();
}