python-validators / validators

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

Domains with underscores fail domain() check? #364

Closed Quix0r closed 5 months ago

Quix0r commented 5 months ago

I have found this domain: tfirefish_01.blueb.me and it fails:

from validators import domain

print(domain('google.com'))
print(domain('tfirefish_01.blueb.me'))

Expected:

True
True

Current:

True
ValidationError(func=domain, args={'value': 'tfirefish_01.blueb.me'})

Python: 3.11.2 Validators: 0.28.0

yozachar commented 5 months ago

Please refer the documentation. Use rfc_2782=True:

validators.domain("tfirefish_01.blueb.me", rfc_2782=True)
Quix0r commented 5 months ago

Cannot this be configured or set once per script run? I have to then modify 14 script positions.

yozachar commented 5 months ago

Sorry, currently no. But you can achieve something similar using an environment variable.

Quix0r commented 5 months ago

Which one do I have to set? I checked the code and found no appearance?

yozachar commented 5 months ago

Well, you could create something like RFC_2782, and use it across your program. This might require one time edit on those 14 instances, but then you're good to go.