mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-24 10:34:03 +03:00
Fix formatting and resolve pre-commit errors
This commit is contained in:
parent
75e1c02019
commit
1a50ea4f9d
|
@ -917,7 +917,7 @@ class CustomLengthValidator:
|
|||
def __call__(self, value):
|
||||
if len(value) < self.min_length:
|
||||
raise ValueError(f"This field must be at least {self.min_length} characters long.")
|
||||
|
||||
|
||||
if self.max_length is not None and len(value) > self.max_length:
|
||||
raise ValueError(f"This field must be no more than {self.max_length} characters long.")
|
||||
|
||||
|
|
|
@ -1071,7 +1071,7 @@ class TestAlphabeticField:
|
|||
invalid_inputs = {
|
||||
'John123': ['This field must contain only alphabetic characters and spaces.'],
|
||||
'Alice!': ['This field must contain only alphabetic characters and spaces.'],
|
||||
'': ['This field must contain only alphabetic characters and spaces.'],
|
||||
'': ['This field must contain only alphabetic characters and spaces.'],
|
||||
}
|
||||
non_string_inputs = [
|
||||
123, # Integer
|
||||
|
@ -1085,7 +1085,7 @@ class TestAlphabeticField:
|
|||
def test_valid_inputs(self):
|
||||
validator = AlphabeticFieldValidator()
|
||||
for value in self.valid_inputs.keys():
|
||||
validator(value)
|
||||
validator(value)
|
||||
|
||||
def test_invalid_inputs(self):
|
||||
validator = AlphabeticFieldValidator()
|
||||
|
@ -1111,7 +1111,7 @@ class TestAlphanumericField:
|
|||
invalid_inputs = {
|
||||
'John!': ['This field must contain only alphanumeric characters (letters and numbers).'],
|
||||
'Alice 007': ['This field must contain only alphanumeric characters (letters and numbers).'],
|
||||
'': ['This field must contain only alphanumeric characters (letters and numbers).'],
|
||||
'': ['This field must contain only alphanumeric characters (letters and numbers).'],
|
||||
}
|
||||
non_string_inputs = [
|
||||
123, # Integer
|
||||
|
@ -1125,7 +1125,7 @@ class TestAlphanumericField:
|
|||
def test_valid_inputs(self):
|
||||
validator = AlphanumericFieldValidator()
|
||||
for value in self.valid_inputs.keys():
|
||||
validator(value)
|
||||
validator(value)
|
||||
|
||||
def test_invalid_inputs(self):
|
||||
validator = AlphanumericFieldValidator()
|
||||
|
@ -1153,12 +1153,12 @@ class TestCustomLengthField:
|
|||
'ab': ['This field must be at least 3 characters long.'], # Too short
|
||||
'abcdefghijk': ['This field must be no more than 10 characters long.'], # Too long
|
||||
}
|
||||
field = str
|
||||
field = str
|
||||
|
||||
def test_valid_inputs(self):
|
||||
validator = CustomLengthValidator(min_length=3, max_length=10)
|
||||
for value in self.valid_inputs.keys():
|
||||
validator(value)
|
||||
validator(value)
|
||||
|
||||
def test_invalid_inputs(self):
|
||||
validator = CustomLengthValidator(min_length=3, max_length=10)
|
||||
|
|
Loading…
Reference in New Issue
Block a user