mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-24 02:24: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):
|
||||
raise ValueError("This field must contain only alphabetic characters and spaces.")
|
||||
|
||||
|
||||
class AlphanumericFieldValidator:
|
||||
"""
|
||||
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):
|
||||
raise ValueError("This field must contain only alphanumeric characters (letters and numbers).")
|
||||
|
||||
|
||||
class CustomLengthValidator:
|
||||
"""
|
||||
Custom validator to ensure the length of a string is within specified limits.
|
||||
|
|
|
@ -172,6 +172,7 @@ class IsAuthenticatedOrReadOnly(BasePermission):
|
|||
request.user.is_authenticated
|
||||
)
|
||||
|
||||
|
||||
class IsAdminUserOrReadOnly(BasePermission):
|
||||
"""
|
||||
Custom permission to only allow admin users to edit an object.
|
||||
|
|
|
@ -1141,6 +1141,7 @@ class TestAlphanumericField:
|
|||
validator(value)
|
||||
assert str(excinfo.value) == "This field must be a string."
|
||||
|
||||
|
||||
class TestCustomLengthField:
|
||||
"""
|
||||
Valid and invalid values for `CustomLengthValidator`.
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from django.test import TestCase
|
||||
|
||||
from rest_framework.status import (
|
||||
is_client_error, is_informational, is_redirect, is_server_error,
|
||||
is_success
|
||||
is_client_error, is_informational, is_redirect, is_server_error, is_success
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ from django.test import TestCase
|
|||
from rest_framework import serializers
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.validators import (
|
||||
BaseUniqueForValidator, UniqueTogetherValidator, UniqueValidator,
|
||||
qs_exists
|
||||
BaseUniqueForValidator, UniqueTogetherValidator, UniqueValidator, qs_exists
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user