Fix formatting and resolve pre-commit errors

This commit is contained in:
Ghosts6 2024-10-19 20:10:57 +01:00
parent 1a50ea4f9d
commit f6ed811e97
7 changed files with 8 additions and 6 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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`.

View File

@ -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
)

View File

@ -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
)