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
1a50ea4f9d
commit
f6ed811e97
|
@ -894,6 +894,7 @@ class AlphabeticFieldValidator:
|
||||||
if not re.match(r'^[A-Za-z ]*$', value):
|
if not re.match(r'^[A-Za-z ]*$', value):
|
||||||
raise ValueError("This field must contain only alphabetic characters and spaces.")
|
raise ValueError("This field must contain only alphabetic characters and spaces.")
|
||||||
|
|
||||||
|
|
||||||
class AlphanumericFieldValidator:
|
class AlphanumericFieldValidator:
|
||||||
"""
|
"""
|
||||||
Custom validator to ensure the field contains only alphanumeric characters (letters and numbers).
|
Custom validator to ensure the field contains only alphanumeric characters (letters and numbers).
|
||||||
|
@ -906,6 +907,7 @@ class AlphanumericFieldValidator:
|
||||||
if not re.match(r'^[A-Za-z0-9]*$', value):
|
if not re.match(r'^[A-Za-z0-9]*$', value):
|
||||||
raise ValueError("This field must contain only alphanumeric characters (letters and numbers).")
|
raise ValueError("This field must contain only alphanumeric characters (letters and numbers).")
|
||||||
|
|
||||||
|
|
||||||
class CustomLengthValidator:
|
class CustomLengthValidator:
|
||||||
"""
|
"""
|
||||||
Custom validator to ensure the length of a string is within specified limits.
|
Custom validator to ensure the length of a string is within specified limits.
|
||||||
|
|
|
@ -172,6 +172,7 @@ class IsAuthenticatedOrReadOnly(BasePermission):
|
||||||
request.user.is_authenticated
|
request.user.is_authenticated
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class IsAdminUserOrReadOnly(BasePermission):
|
class IsAdminUserOrReadOnly(BasePermission):
|
||||||
"""
|
"""
|
||||||
Custom permission to only allow admin users to edit an object.
|
Custom permission to only allow admin users to edit an object.
|
||||||
|
|
|
@ -1141,6 +1141,7 @@ class TestAlphanumericField:
|
||||||
validator(value)
|
validator(value)
|
||||||
assert str(excinfo.value) == "This field must be a string."
|
assert str(excinfo.value) == "This field must be a string."
|
||||||
|
|
||||||
|
|
||||||
class TestCustomLengthField:
|
class TestCustomLengthField:
|
||||||
"""
|
"""
|
||||||
Valid and invalid values for `CustomLengthValidator`.
|
Valid and invalid values for `CustomLengthValidator`.
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from rest_framework.status import (
|
from rest_framework.status import (
|
||||||
is_client_error, is_informational, is_redirect, is_server_error,
|
is_client_error, is_informational, is_redirect, is_server_error, is_success
|
||||||
is_success
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,7 @@ from django.test import TestCase
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
from rest_framework.validators import (
|
from rest_framework.validators import (
|
||||||
BaseUniqueForValidator, UniqueTogetherValidator, UniqueValidator,
|
BaseUniqueForValidator, UniqueTogetherValidator, UniqueValidator, qs_exists
|
||||||
qs_exists
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user