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.
|
||||
|
|
|
@ -157,4 +157,4 @@ class OwnershipTestModel(models.Model):
|
|||
title = models.CharField(max_length=100)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
return self.title
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -819,4 +819,4 @@ class PermissionTests(TestCase):
|
|||
self.assertTrue(permission.has_object_permission(request, None, obj))
|
||||
|
||||
request.user = self.admin_user
|
||||
self.assertTrue(permission.has_object_permission(request, None, obj))
|
||||
self.assertTrue(permission.has_object_permission(request, None, obj))
|
||||
|
|
|
@ -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