protected function validate(ApiServiceInterface $service)
    {
        $validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
        $violations = $validator->validate($service);
        /** @var ConstraintViolation $violation */
        foreach ($violations as $violation) {
            $errorMessage = $violation->getMessage();
            if ($violation->getPropertyPath()) {
                $errorMessage = sprintf('Error in field "%s": ', $violation->getPropertyPath()) . $errorMessage;
            }
            throw new InvalidApiDataException($errorMessage);
        }
    }
protected function validate(ApiServiceInterface $service)
    {
        $validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
        $violations = $validator->validate($service);
        /** @var ConstraintViolation $violation */
        foreach ($violations as $violation) {
            $errorMessage = $violation->getMessage();
            if ($violation->getPropertyPath()) {
                $errorMessage = sprintf('Error in field "%s": ', $violation->getPropertyPath()) . $errorMessage;
            }
            throw new InvalidApiDataException($errorMessage);
        }
    }
protected function validate ( ApiServiceInterface $ service ) { $ validator = Validation :: createValidatorBuilder ( ) -> enableAnnotationMapping ( ) -> getValidator ( ) ; $ violations = $ validator -> validate ( $ service ) ; /** @var ConstraintViolation $violation */ foreach ( $ violations as $ violation ) { $ errorMessage = $ violation -> getMessage ( ) ; if ( $ violation -> getPropertyPath ( ) ) { $ errorMessage = sprintf ( 'Error in field "%s": ' , $ violation -> getPropertyPath ( ) ) . $ errorMessage ; } throw new InvalidApiDataException ( $ errorMessage ) ; } }
Validate a service data using Symfony validation component

@param ApiServiceInterface $service

@throws InvalidApiDataException
Validate a service data using Symfony validation component