protected function buildValidation($class = null)
    {
        $validations = [];
        $metadata = $this->validator->getMetadataFor($class);
        $entityConstraints = [];
        foreach ($metadata->getConstraints() as $constraint) {
            $class = new \ReflectionClass($constraint);
            $fields = $constraint->fields;
            $entityConstraint = [implode(', ', (array) $fields) => $constraint->message];
            $entityConstraints = array_merge($entityConstraints, $entityConstraint);
            $validations[$class->getShortName()] = $entityConstraint;
        }

        foreach ($metadata->getConstrainedProperties() as $property) {
            $constraints = $metadata->getPropertyMetadata($property)[0]->constraints;
            $result = [];
            foreach ($constraints as $constraint) {
                $class = new \ReflectionObject($constraint);
                switch ($name = $class->getShortName()) {
                    case 'True':
                        $result[$name] = $constraint->message;
                        break;
                    case 'NotBlank':
                        $result[$name] = $constraint->message;
                        break;
                    case 'Type':
                        $result[$name] = $constraint->type;
                        break;
                    case 'Length':
                        $result[$name] = $this->constraintMessages($constraint);
                        break;
                    case 'Count':
                        $result[$name] = $this->constraintMessages($constraint);
                        break;
                }
            }
            $validations[$property] = $result;
        }

        return $validations;
    }