-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add Xml
constraint
#57365
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
base: 7.3
Are you sure you want to change the base?
Conversation
src/Symfony/Component/Validator/Tests/Constraints/YamlValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/YamlValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/AbstractFormatValidator.php
Outdated
Show resolved
Hide resolved
|
9708e02
to
1edfe83
Compare
I've made the following changes:
|
Xml
constraint
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.
Needs a rebase
4716da3
to
ebdab1f
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.
Just a few nitpicks 🙂 Nice PR!
src/Symfony/Component/Validator/Tests/Constraints/XmlValidatorTest.php
Outdated
Show resolved
Hide resolved
539154e
to
ea4c209
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.
Asserting that a file is XML is pretty weak as a check: one always expects some structure in the XML. It'd be natural to me to allow passing an XSD, isn't it? Up to improve the PR in this direction?
b7ae934
to
08515a5
Compare
src/Symfony/Component/Validator/Tests/Constraints/XmlValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/XmlValidatorTest.php
Outdated
Show resolved
Hide resolved
@nicolas-grekas Thank you for your feedback. The constraint is intended to assert a string value rather than a file. |
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
Any updates? |
I also think that supporting validating the XML content against a schema would make this feature more useful. |
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.
Status: needs work
Still up to continue the PR?
@nicolas-grekas Yes, I'll work on it when I have some free time. |
92712d9
to
0a18fe2
Compare
@nicolas-grekas & @fabpot: Thanks again for the feedback. XSD schema validation is now supported. |
) { | ||
parent::__construct(null, $groups, $payload); | ||
|
||
if (null !== $this->schemaPath && !file_exists($this->schemaPath)) { |
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.
Let's use is_readable()
to ensure that the file exists and can actually be read:
if (null !== $this->schemaPath && !file_exists($this->schemaPath)) { | |
if (null !== $this->schemaPath && !is_readable($this->schemaPath)) { |
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.
In this case, you also need to change the error message: "file does not exist or cannot be read".
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.
Thanks for your valuable feedback. Resolved
0a18fe2
to
5241b22
Compare
Add
Xml
constraint