python-validators / validators

Python Data Validation for Humans™.
MIT License
958 stars 152 forks source link

feat: add extra schemes to url validation #396

Closed humbertogontijo closed 1 month ago

humbertogontijo commented 1 month ago

This allows for a more flexible scheme validation

yozachar commented 1 month ago

Hi @humbertogontijo, thanks for the PR. Such URLs bAdScHeMa://github.com will be validated if extra_schemes = {'bAdScHeMa',}.

Say a library user provides a domain name, which now suppose is validated against itself, wouldn't that defeat the purpose of domain validation? I think so.

We do plan to support more schemas, see #388.


validators.url method already has a lot of parameters, wouldn't adding more, clutter it? WDYT?

humbertogontijo commented 1 month ago

The idea is to just add custom schemes. For my purpose it would be for Telegram https://core.telegram.org/api/links

I do agree that this is more a URI than URL stuff though. But it would workout while uri validation is not available

yozachar commented 1 month ago

Yes, it will work, but that is no reason for doing counter-intuitive validation. If a huge number of schemas need to be validated, something like TLD validation can be performed.

Also tg:// links need not follow the classical http URL syntax, which therefore will return ValidationError regardless of the scheme.

So is it worth it, what do you think?

humbertogontijo commented 1 month ago

Thats ok. Thank you