Skip to content

Validation translation domain should respect the Translator translationDomain #134

@axi

Description

@axi

string "validators" translation domain should respect the Translator translationDomain witch can be modified through configuration (validator.translation_domain: my_custom_validation_translation_domain).

See in Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation

    /**
     * @param array $constraints
     */
    private function extractFromConstraints(array $constraints)
    {
        foreach ($constraints as $constraint) {
            $ref = new \ReflectionClass($constraint);
            $defaultValues = $ref->getDefaultProperties();

            $properties = $ref->getProperties();

            foreach ($properties as $property) {
                $propName = $property->getName();

                // If the property ends with 'Message'
                if ('message' === strtolower(substr($propName, -1 * strlen('Message')))) {
                    // If it is different from the default value
                    if ($defaultValues[$propName] !== $constraint->{$propName}) {
                        $this->addLocation($constraint->{$propName}, 0, null, ['domain' => 'validators']);
                    }
                }
            }
        }
    }

Not sure of the best way to do this, any idea ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions