Should documentation discuss how validators work together (and their ordering)? #8916
Unanswered
MimmyJau
asked this question in
Ideas & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
I was going through the docs trying to understand if a custom field-level
def validate_<field_name>(self, value):
function (specified here in the docs) would override the default validators.Example
While this example is a bit contrived, suppose I had a
models.PositiveIntegerField
field and wanted to set a maximum value on it (using a custom validator). Would I then have to re-validate that it was still a positive integer (something handled by the default validator)?Suggestion
The docs could give a brief overview of how the multiple validators work in conjunction with one another (e.g. that custom validators don't override default validators but instead extend them). The best summary I could find so far was in the answers to this StackOverflow question (the top two in particular).
Moreover, should there be a high-level overview of the ordering of validation? i.e.
validators=[]
parameterdef validate_<field_name>:
def validate(self, data):
I would offer to do this, but I'm not sure I even fully understand it myself yet. That being said, I'm happy to contribute where I can.
Beta Was this translation helpful? Give feedback.
All reactions