Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Validator] add number constraints#28637
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ac485ee to77ba93aComparesrc/Symfony/Component/Validator/Constraints/NegativeValidator.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Constraints/NegativeValidator.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Constraints/NegativeOrZeroValidator.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
6f25560 to5a92e1bCompareostrolucky commentedSep 30, 2018
What about null values? |
5a92e1b to0b6e408Comparejschaedl commentedSep 30, 2018
@ostrolucky I think it should do nothing for null values. I will add a condition and a test. |
xabbuh commentedSep 30, 2018
I think we could save plenty of code here if the constraints were just specialised versions of the already existing |
ro0NL commentedSep 30, 2018
like |
xabbuh commentedSep 30, 2018
yes |
ostrolucky commentedSep 30, 2018
Better fit is GreaterThan*/LessThan*. No new validators would be required then |
xabbuh commentedSep 30, 2018
indeed, those fit better than |
jschaedl commentedOct 5, 2018
@ostrolucky Do you mean we don't need the new |
73e1e81 to43aef65Comparejschaedl commentedOct 5, 2018
43aef65 to40aa6cdComparero0NL commentedOct 5, 2018
@jschaedl actually i expected it like: then |
ostrolucky commentedOct 5, 2018
Yep, like@ro0NL says. Well, not exactly (validatedBy needs to be specified and minimum value maybe tweaked) but mostly just that. |
84de93c to63fa241Compare
OskarStark left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nice improvement
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
63fa241 tod2073e5CompareUh oh!
There was an error while loading.Please reload this page.
ostrolucky left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Like I explained in#28637 (comment) since these constraints don't accept any default value, their constructor shouldn't default tonull
ro0NL commentedNov 16, 2018
IMHO it should, so we get the expected exception herehttps://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraint.php#L136 Also we could make |
ostrolucky commentedNov 16, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
These constraints are designed in a way they will never pass It would make some sense in case message is default property, but I don't think somebody would approve such change. |
8f7388a to2c07ac2CompareUh oh!
There was an error while loading.Please reload this page.
7119701 to35bfa5aCompare189d578 to0e31c3bCompareUh oh!
There was an error while loading.Please reload this page.
e476040 toc77ef3bCompare
fabpot left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ready to be merged after the translation files are fixed.
src/Symfony/Component/Validator/Resources/translations/validators.de.xlf OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
OskarStark commentedMar 31, 2019
@jschaedl could you please send a Docs PR for this new feature? |
e718297 toc973ceeComparejschaedl commentedMar 31, 2019
@OskarStark I am already working on it. :-) |
c973cee to0187039Comparefabpot commentedMar 31, 2019
Thank you@jschaedl. |
This PR was squashed before being merged into the 4.3-dev branch (closes#28637).Discussion----------[Validator] add number constraints| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#28608| License | MIT| Doc PR | tbd.I added the following constraints:* `Positive`* `PositiveOrZero`* `Negative`* `NegativeOrZero`Commits-------0187039 [Validator] add number constraints
This PR was squashed before being merged into the master branch (closes#11254).Discussion----------[Validator] Add docs for number constraintsFeature PR:symfony/symfony#28637- [x] Positive- [x] PositiveOrZero- [x] Negative- [x] NegativeOrZero### Todo:- [x] find a better example for `NegativeOrZero` constraintCommits-------8022292 [Validator] Add docs for number constraints
Uh oh!
There was an error while loading.Please reload this page.
I added the following constraints:
PositivePositiveOrZeroNegativeNegativeOrZero