Symfony\Component\Validator\Validator::validatePropertyValue PHP Method

validatePropertyValue() public method

{@inheritDoc}
public validatePropertyValue ( $class, $property, $value, $groups = null )
    public function validatePropertyValue($class, $property, $value, $groups = null)
    {
        $metadata = $this->metadataFactory->getClassMetadata($class);

        $walk = function(GraphWalker $walker, $group) use ($metadata, $property, $value) {
            return $walker->walkPropertyValue($metadata, $property, $value, $group, '');
        };

        return $this->validateGraph($class, $walk, $groups);
    }

Usage Example

コード例 #1
0
ファイル: ValidatorTest.php プロジェクト: TuxCoffeeCorner/tcc
 /**
  * @expectedException \Symfony\Component\Validator\Exception\ValidatorException
  */
 public function testValidatePropertyValueFailsIfPropertiesNotSupported()
 {
     // $metadata does not implement PropertyMetadataContainerInterface
     $metadata = $this->getMock('Symfony\\Component\\Validator\\MetadataInterface');
     $this->metadataFactory = $this->getMock('Symfony\\Component\\Validator\\MetadataFactoryInterface');
     $this->metadataFactory->expects($this->any())->method('getMetadataFor')->with('VALUE')->will($this->returnValue($metadata));
     $this->validator = new Validator($this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator());
     $this->validator->validatePropertyValue('VALUE', 'someProperty', 'propertyValue');
 }