8000 Bug with constraint attach to a field ( using @Assert\True() annotation ) · Issue #18700 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Bug with constraint attach to a field ( using @Assert\True() annotation ) #18700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AdriwanKenoby opened this issue May 3, 2016 · 8 comments
Closed

Comments

@AdriwanKenoby
Copy link

When I try to add a custom constraint for a specific field with a method, the return statement is always false.

The same method use to verify form globaly works nice.

This method was named isUrl() in my case and verify if an url is online ( i check the header code with a curl request ).

I thought it was because i use the specific word "url" which could be use in otherway. But even if I change "url" in "path". I have the same issue.

@xabbuh
Copy link
Member
xabbuh commented May 3, 2016

@AdriwanKenoby Can you fork the Symfony Standard Edition and make the changes that are needed to reproduce your issue?

@AdriwanKenoby
Copy link
Author
AdriwanKenoby commented May 4, 2016

I think its a symfony bug but it can be an Oro platform issue.

My code is available on http://gitlab.sinabs.ovh/orocrm-projects/sinabs-orocrm/

@xabbuh
Copy link
Member
xabbuh commented May 4, 2016

@AdriwanKenoby Sorry, but we cannot check your whole project. Stripping it down to a minimal set of changes to reproduce your issue or providing a failing test case is the only way I see to help you with your issue.

@jakzal
Copy link
Contributor
jakzal commented Jun 27, 2016

@AdriwanKenoby any chance to get what xabbuh's asking for please?

@AdriwanKenoby
Copy link
Author

@xabbuh

Sorry for the time, i have found a workaround to my problem, i write a custom validator and declare it as a service, then i use callbak annotation to validate my field. My code is no longer public on gitlab, so I build a minimal project symfony with the bug i had found, i attach it to this message.

Their is an entity named Test with a field named url. The method named isUrl return always false, even if it should return true. If i named this method isTestValid, it works.
test.tar.gz

@jzawadzki
Copy link
Contributor
jzawadzki commented Dec 3, 2016

I just tried to replicate that issue and I can confirm it, however I'm not sure if it can be easily fixed.

Issue here is when there is an entity validated that have both getter and isser of same form field - in that situation constraints are taken from both methods, but their are validated againts value of getter only.

In @AdriwanKenoby example there was form field url based on entity Test which had getUrl() method and isUrl() method with IsTrue assert put on it.
In that situation IsTrue constraint is validated against value of getUrl() instead against value of isUrl()

Here you can find forked symfony-standard showing the issue: jzawadzki/symfony-standard@ec00a7b

@xabbuh
Copy link
Member
xabbuh commented Dec 31, 2016
B09D

Thank you @AdriwanKenoby for the bug report and thank you very much @jzawadzki for investing the time into find out what went wrong. I was now able to reproduce the issue and create a patch for it in #21115. Can you please try it out and confirm that that PR fixes your issue?

@fabpot
Copy link
Member
fabpot commented Feb 16, 2017

@AdriwanKenoby Can you confirm that @xabbuh's PR fixes your issue?

fabpot added a commit that referenced this issue Feb 19, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

[Validator] do not guess getter method names

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #5219, #18700
| License       | MIT
| Doc PR        | TODO

Commits
-------

bd3a90a [Validator] do not guess getter method names
@fabpot fabpot closed this as completed Feb 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0