-
-
Notifications
You must be signed in to change notification settings - Fork 933
Add support for generating property schema format for Url and Hostname #4185
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
Add support for generating property schema format for Url and Hostname #4185
Conversation
fe91074
to
27825b7
Compare
Please remove me from the description 😆 I'm already checking https://github.com/api-platform/core/pulse from time to time these days (also I'm not part of the team) If it may help: the test failure for "lowest" is related to symfony/validator@adab212 (introduced in v4.4.8) But string manipulation and generating a huge pattern in the schema... is it really worth it? 🤔 Wouldn't it be enough to add something like this in the existing if ($constraint instanceof Email) {
return ['format' => 'email'];
}
+
+ if ($constraint instanceof Url) {
+ return ['format' => 'uri'];
+ }
if ($constraint instanceof Uuid) {
return ['format' => 'uuid'];
} This would not be strictly equivalent (also ambiguity between "URL", "URI" and "URI reference"), but that's already true for Anyway let's wait for a proper review from a team member 😄 |
I just cc'ed because you were interested in these PR's :D |
IMHO if backend validates based on some pattern then it should be exposed nevertheless.. |
ebb332e
to
02a6efa
Compare
Included also Hostname constraint as it's uri related |
I agree with @guilliamxavier. Since the format is used, I don't think it's a good idea to have the regexp as well. |
But how would you distinguish then allowing only some other specific protocols? |
You would not be able to, that's right. Personally, I think it's a little bit too much detailed though. And the implementation is very dependent of the pattern in |
02a6efa
to
925332a
Compare
src/Bridge/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaUrlRestriction.php
Outdated
Show resolved
Hide resolved
925332a
to
942013b
Compare
942013b
to
cca1ba5
Compare
cca1ba5
to
989df9a
Compare
Removed the pattern part. |
Tyvm @norkunas ! |
Add a
PropertySchemaUrlRestriction
to transform Url validation constraint into json schema.