linkding/bookmarks/validators.py

16 lines
449 B
Python
Raw Normal View History

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
"""
2024-01-27 10:29:16 +00:00
def __call__(self, value):
if settings.LD_DISABLE_URL_VALIDATION:
return
2024-01-27 10:29:16 +00:00
super().__call__(value)