python-validators/validators

Domains with underscores fail domain() check?

Closed this issue ยท 5 comments

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

Please refer the documentation. Use rfc_2782=True:

validators.domain("tfirefish_01.blueb.me", rfc_2782=True)

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

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

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

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.