1+ import re
2+
13from django .core .exceptions import ValidationError
24from django .core .validators import RegexValidator
35from django .utils .deconstruct import deconstructible
46from django .utils .encoding import force_str
57from django .utils .translation import gettext_lazy as _
6-
78from localflavor .generic .countries .iso_3166 import ISO_3166_1_ALPHA2_COUNTRY_CODES
89
910
@@ -28,7 +29,7 @@ def validate_country(value: str) -> None:
2829 )
2930
3031
31- def validate_charfield_entry (value , allow_apostrophe = False ):
32+ def validate_charfield_entry (value : str , allow_apostrophe = False ):
3233 """
3334 Validates a charfield entry according with Belastingdienst requirements.
3435
@@ -57,6 +58,8 @@ def validate_charfield_entry(value, allow_apostrophe=False):
5758
5859@deconstructible
5960class RegexWithDisallowedPrefixesValidator (RegexValidator ):
61+ regex : re .Pattern [str ]
62+
6063 def __init__ (self , * args , ** kwargs ):
6164 self .disallowed_prefixes = kwargs .pop ("disallowed_prefixes" )
6265 self .message_disallowed_prefix = kwargs .pop ("message_disallowed_prefix" )
@@ -99,7 +102,7 @@ def __call__(self, value):
99102 """
100103 Validates that the input matches the regular expression.
101104 """
102- if not self .regex .search (force_str (value )):
105+ if not self .regex .search (force_str (value )): # type: ignore[reportAttributeAccessIssue]
103106 message = "{0}: {1}" .format (self .message , force_str (value ))
104107 raise ValidationError (message , code = self .code )
105108
@@ -115,7 +118,7 @@ def __call__(self, value):
115118)
116119
117120validate_no_space = CustomRegexValidator (
118- regex = "^[\S]+$" , message = _ ("Geen spaties toegestaan" )
121+ regex = r "^[\S]+$" , message = _ ("Geen spaties toegestaan" )
119122)
120123
121124validate_bag_id = CustomRegexValidator (
0 commit comments