-
-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support validator=, validators=, or validate_with=. #645
Comments
+1 for validator. Even if validator accept multiple validators, it can be recognized as "a validator bulit with a combination of validators". |
I agree Currently,
definitely looks weird.
could do, like @monotaro-yasushi-masuda says, it is a compound validator so singular form is understandable, but it is still surprising to provide a collection to a singular argument. The most natural thing, of course, would be to use But most of the time we only use one validator, so the shortcut allowing a callable is nice. There's a trade-off here between clarity and practicality (and history). Keeping the ability to pass only a callable would be nice. In this case, At least, keeping |
IIRC, this was the reason for choosing "validate." I wouldn't consider |
Closing this, as it has gone stale and I'm still not convinced that the OP is a significant improvement over the status quo to justify a breaking change. |
In field constructors, validate=validation_function doesn't flow naturally in English.
An average person, before reading the docs, might think that a parameter named "validate" would take a boolean and turn validation on or off, like "strict".
For a single validator, Field(validator=is_lowercase) sounds more natural.
For multiple validators, Field(validators=[is_lowercase, is_alphanumeric]) sounds more natural.
For convenience, these could be aliases of the same method, although I can't think of a case where a developer-user of this API would not know whether they're validating with one or multiple functions.
The text was updated successfully, but these errors were encountered: