-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Add url to validation #2874
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 url to validation #2874
Conversation
I assume this came out of the |
@@ -255,6 +256,17 @@ def time_zone(value): | |||
weekdays = vol.All(ensure_list, [vol.In(WEEKDAYS)]) | |||
|
|||
|
|||
def url(value: Any) -> str: |
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 not call it url, as a url can contain any protocol. Let's call it http_url
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.
hmm, although it can obviously also be https…
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 think it's fine as url
. The definition of URL is that it is a universal resource locator, not something specifically made for HTTP(S) only. And it keeps our existing syntax of cv.string
, cv.bool
, etc.
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.
url is correct.
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.
ok let's do url.
Good to merge when linting passes 👍 |
Description:
Shortcut for the validation of URLs.
voluptuous
is usingurllib.parse
to validate an URL but I think that we should be more restrictive and only allowhttp
/https
ashtp
will definitely not lead to a success.Schemas for REST/aREST could benefit from this.
Related issue (if applicable): fixes #2800
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#
Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass