Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
dj-kaos-utils / validators.py
Size: Mime:
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)