MCPcopy Create free account
hub / github.com/encode/django-rest-framework / UniquenessIntegerSerializer

Class UniquenessIntegerSerializer

tests/test_validators.py:68–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67
68class UniquenessIntegerSerializer(serializers.Serializer):
69 # Note that this field *deliberately* does not correspond with the model field.
70 # This allows us to ensure that `ValueError`, `TypeError` or `DataError` etc
71 # raised by a uniqueness check does not trigger a deceptive "this field is not unique"
72 # validation failure.
73 integer = serializers.CharField(validators=[UniqueValidator(queryset=IntegerFieldModel.objects.all())])
74
75
76class TestUniquenessValidation(TestCase):

Calls 1

UniqueValidatorClass · 0.90