Giter Club home page Giter Club logo

Comments (10)

xabbuh avatar xabbuh commented on June 4, 2024 1

@mablae You can check if the Symfony\Component\Validator\Context\ExecutionContextInterface interface does exist (which was introduced in Symfony 2.5):

if (interface_exists('Symfony\Component\Validator\Context\ExecutionContextInterface')) {
    // Symfony 2.5 or higher
} else {
    // Symfony before 2.5
}

from phone-number-bundle.

ste93cry avatar ste93cry commented on June 4, 2024 1

I've prepared a PR to fix this issue. I had to adapt the code to work both for Symfony < 2.5 and Symfony 2.5+. Raising the requirements of Symfony to at least 2.7 which is LTS would help with future tickets too and would make life easier because we could simplify some parts of the code that are now a real mess, e.g. the unit tests that have to handle different ExecutionContext classes (I don't remember in which version it was added but I know that there is now a documented trait to use for the unit tests of a validator that should handle all cases).

from phone-number-bundle.

ste93cry avatar ste93cry commented on June 4, 2024 1

ping @rh389 can we please move forward on this if it's still valid?

from phone-number-bundle.

thewilkybarkid avatar thewilkybarkid commented on June 4, 2024

The bundle supports versions before 2.5 (ie 2.3) so can't use buildViolation() yet. Future versions can do.

Regarding the path, this sounds like #19.

from phone-number-bundle.

xabbuh avatar xabbuh commented on June 4, 2024

@thewilkybarkid You could do the buildValidation() call conditionally (depending on the installed version of the Validator component).

from phone-number-bundle.

rafaelschmitt avatar rafaelschmitt commented on June 4, 2024

@thewilkybarkid ok i understand, you are right. Then the idea of xabbuh could be a solution.
Or you could maybe then replace addViolation with addViolationAt and do so:

private function addViolation($value, Constraint $constraint)
    {
        $this->context->addViolationAt(
            $constraint->atPath,
            $constraint->message,
            array('{{ type }}' => $constraint->type, '{{ value }}' => $value)
        );
    }

It would be really nice if you would give an option to decide where the violation message should appear.

from phone-number-bundle.

 avatar commented on June 4, 2024

@thewilkybarkid What's about a master-branch for Symfony 2.7+, 2.8+ or 3.0+ and a current stable branch for the current code? Then you could use these new features.

from phone-number-bundle.

mablae avatar mablae commented on June 4, 2024

Interesting. @xabbuh can you give an example how such a version check would be done proplery?

from phone-number-bundle.

ste93cry avatar ste93cry commented on June 4, 2024

ping @thewilkybarkid any news on this? PR is ready to be reviewed

from phone-number-bundle.

robhogan avatar robhogan commented on June 4, 2024

#108 is now merged, so closing this.

from phone-number-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.