python-validators / validators

Python Data Validation for Humans™.
MIT License
977 stars 155 forks source link

URL Validation: Add support for other schemes apart from https, http, ftp #327

Closed dvignacioglobal closed 7 months ago

dvignacioglobal commented 8 months ago

Given in the documentation link, the validator does not return True if I use a different scheme such as rtmp or rtsp.

  foo://admin:hunter1@example.com:8042/over/there?name=ferret#nose
  \_/   \___/ \_____/ \_________/ \__/\_________/ \_________/ \__/
   |      |       |       |        |       |          |         |
scheme username password hostname port    path      query    fragment

An example of this is

rtmp://192.168.1.123:1935/live/test

If I run this code:

import validators

streamurl = "rtmp://192.168.1.123:1935/live/test"
print(validators.url(streamurl))

The output is:

ValidationError(func=url, args={'value': 'rtmp://192.168.1.123:1935/live/test'})

It would be nice if the URL validator supports other schemes. Thanks.

yozachar commented 7 months ago
"ftp", "ftps", "git", "http", "https",
"rtmp", "rtmps", "rtsp", "sftp",
"ssh", "telnet",

Apart from these, do you have any other protocols in mind that follows a similar scheme://netloc/path;parameters?query#fragment syntax?

dvignacioglobal commented 7 months ago

Thanks for replying! I have nothing more to add to the list.

nyuware commented 5 months ago

Opening the issue again, would it be possible to parse all the available schemes from IANA available here instead of hardcoding a list ? Like it's already being done for the TLDS Thanks!

yozachar commented 5 months ago

parse all the available schemes from IANA

Would be impractical. Hence to cover as much as possible #352 exists.

tofetpuzo commented 4 months ago

is this feature still live?

yozachar commented 4 months ago

is this feature still live?

What are you referring to specifically?

tofetpuzo commented 4 months ago

is this feature still live?

What are you referring to specifically?

Hey @yozachar here -> "feature add non-exhaustive Url validation"

yozachar commented 4 months ago

is this feature still live?

What are you referring to specifically?

Hey @yozachar here -> "feature add non-exhaustive Url validation"

Yes