Skip to content

Conversation

@Limsunoh
Copy link
Contributor

…ator to validators

I have made things!

Serializer.validators now has the Unique... validators type added to it.

Related issues

Format is:

I'm a newbie developer.
If you have any feedback, just write it here.

It can be whatever you want!


Validator: TypeAlias = Callable[[_V], None] | ContextValidator[_V]
Validator: TypeAlias = (
Callable[[_V], None] | ContextValidator[_V] | UniqueValidator | UniqueTogetherValidator | BaseUniqueForValidator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change shouldn't be necessary.

But this was quite tricky to figure out, it would help if it was explained in a comment.

And the Validator type alias would be better called FieldValidator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand, what was asked in the original issue

was actually different. The Serializer class inherits a validators property from Field class (@property def validators(self) -> list[Validator[_VT]] from Field class.

What it doesn't account for is that in case of Serializer class, validators in that case actually can include UniqueTogetherValidator and others.

Copy link
Contributor

@intgr intgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! I wrote these comments a week ago, but forgot to submit the review. Sorry!

@intgr intgr self-assigned this Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants