linkding/bookmarks/validators.py
Sascha Ißbrücker 91d876a7f1
Add option to disable bookmark URL validation (#57)
* Add option for disabled bookmark URL validation (#36)

* Add options documentation (#36)
2021-02-06 16:27:19 +01:00

14 lines
No EOL
447 B
Python

from django.conf import settings
from django.core import validators
class BookmarkURLValidator(validators.URLValidator):
"""
Extends default Django URLValidator and cancels validation if it is disabled in settings.
This allows to switch URL validation on/off dynamically which helps with testing
"""
def __call__(self, value):
if settings.LD_DISABLE_URL_VALIDATION:
return
super().__call__(value)