-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Added HostnameValidator #31518
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
@karser thanks for this contribution! I like this a lot ... except for the Here's a proposal:
|
@javiereguiluz thanks for the feedback. I implemented your proposal (see the test cases). wdyt?
The option |
src/Symfony/Component/Validator/Constraints/DomainValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Tests/Constraints/DomainValidatorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/DomainValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/DomainValidator.php
Outdated
Show resolved
Hide resolved
f650936
to
98f6a2e
Compare
src/Symfony/Component/Validator/Constraints/DomainValidator.php
Outdated
Show resolved
Hide resolved
69d879a
to
5bdd6c3
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.
would DomainName
be a more inuitive name?
also please update validation.en.xml + any language you know :)
src/Symfony/Component/Validator/Constraints/DomainValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/DomainValidator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Constraints/DomainValidator.php
Outdated
Show resolved
Hide resolved
d930263
to
13d3e65
Compare
aa3170f
to
e6fc5af
Compare
src/Symfony/Component/Validator/Constraints/HostnameValidator.php
Outdated
Show resolved
Hide resolved
e6fc5af
to
465c68d
Compare
465c68d
to
c85b5c1
Compare
c85b5c1
to
8a08c20
Compare
really looking forward for this 👍 |
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.
with some minor comments
'You can register them by adding a new driver to the '. | ||
'"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver') | ||
)); | ||
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.'You can register them by adding a new driver to the '.'"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver'))); |
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.
This should be reverted.
'The user object has to be serialized with its own identifier '. | ||
'mapped by Doctrine.' | ||
); | ||
throw new \InvalidArgumentException('You cannot refresh a user '.'from the EntityUserProvider that does not contain an identifier. '.'The user object has to be serialized with its own identifier '.'mapped by Doctrine.'); |
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.
This should be reverted.
@@ -1,6 +1,10 @@ | |||
CHANGELOG | |||
========= | |||
|
|||
5.1.0 | |||
----- | |||
* added the `Hostname` constraint and validator |
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.
missing blank line above the entry.
Thank you @karser. |
This PR was merged into the 5.1-dev branch. Discussion ---------- [Validator] Added HostnameValidator | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #10088 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> This PR adds HostnameValidator support. I encountered this need in my project and was surprised that this issue has been open for years. Here is short example: ``` App\Entity\Acme: properties: domain: - Hostname: ~ non_tld_domain: - Hostname: { requireTld: false } ``` The option `requireTld` is `true` by default and disallows domains like localhost and etc. Commits ------- 8a08c20 Added HostnameValidator
This PR adds HostnameValidator support. I encountered this need in my project and was surprised that this issue has been open for years.
Here is short example:
The option
requireTld
istrue
by default and disallows domains like localhost and etc.