-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add new json Validator #28477
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
Conversation
2d4352b
to
ddd393c
Compare
src/Symfony/Component/Validator/Constraints/IsJsonValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/IsJsonValidator.php
Outdated
Show resolved
Hide resolved
c61fa99
to
24a15c2
Compare
Hi @onEXHovia , @apfelbox , |
Look here: #28477 (comment) Can you see it with this link? |
src/Symfony/Component/Validator/Constraints/NotJsonValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/NotJsonValidator.php
Outdated
Show resolved
Hide resolved
For the early exit, see: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/BicValidator.php#L29-L31 (and the other validators) But for the "it has to be filled part" you should use |
src/Symfony/Component/Validator/Tests/Constraints/NotJsonValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/NotJsonValidatorTest.php
Outdated
Show resolved
Hide resolved
0c13707
to
b061fcf
Compare
src/Symfony/Component/Validator/Tests/Constraints/JsonValidatorTest.php
Outdated
Show resolved
Hide resolved
801f88e
to
0ed8620
Compare
0ed8620
to
d59691b
Compare
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 :) one last minor comment.
5887556
to
b8e7c7d
Compare
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.
Can you resolve the conflict? Besides that this looks good to me.
Sorry to come late here, but what's the purpose of a JSON validator? |
I've at least added this once in a project, to validate (for the backend) arbitrary JSON sent by DraftJS. No decoding, just accepting json strings. |
Hi, we used to validate a lot of normal string inputs filled by contributors to see if valid JSON or not before saving them to the database. ( Application that provides configs as JSON used by other applications ). I'm not sure if it was the best way to provide configs but it was something like Cloudformation. |
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.
LGTM, needs rebase
ce33faa
to
cc65f3c
Compare
@chalasr rebase done :) |
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.
I left a minor comment, but I like this. Thanks @zairigimad.
c4616c2
to
13ba8ad
Compare
@@ -330,6 +330,10 @@ | |||
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source> | |||
<target>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</target> | |||
</trans-unit> | |||
<trans-unit id="85"> |
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.
Should be 86.
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.
see 21b8efc
13ba8ad
to
131febc
Compare
Thank you @zairigimad. |
This PR was squashed before being merged into the 4.3-dev branch (closes #28477). Discussion ---------- [Validator] Add new json Validator | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT | Doc PR | symfony/symfony-docs#10351 Hi, in so many cases we want to test if a value is a valid json or not, so I propose this new ~~NotJson~~ `Json` constraint for this need. cordially, Commits ------- 131febc [Validator] Add new json Validator
…imad) This PR was squashed before being merged into the master branch (closes #10351). Discussion ---------- [Validator] Add new json Validator Documentation Hi, introduce ~~IsJson~~ `Json` Constraint . this is a documentation for the new feature in the pull request symfony/symfony#28477 cordially, Commits ------- 01ea746 [Validator] Add new json Validator Documentation
The files were added as executable via symfony#28477.
This PR was merged into the 4.3 branch. Discussion ---------- Drop useless executable bit The files were added as executable via #28477. | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 7905863 Drop useless executable bit
Hi,
in so many cases we want to test if a value is a valid json or not, so I propose this new
NotJsonJson
constraint for this need.cordially,