Repository URL to install this package:
|
Version:
0.0.1 ▾
|
dj-kaos-utils
/
validators.py
|
|---|
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
class FullMatchRegexValidator(RegexValidator):
def __call__(self, value):
"""
Validate that the input is (or is *not*, if
inverse_match is True) a full match for the regular expression.
"""
match = self.regex.fullmatch(str(value))
invalid_input = match if self.inverse_match else not match
if invalid_input:
raise ValidationError(self.message, code=self.code)