Skip to content

Question: Validator Parameter Requirements #1183

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

Closed
keironstoddart opened this issue Sep 8, 2023 · 1 comment
Closed

Question: Validator Parameter Requirements #1183

keironstoddart opened this issue Sep 8, 2023 · 1 comment

Comments

@keironstoddart
Copy link

Why do validators require three parameters (self, attribute, value)? Can't the value just be pulled from self? I am also failing to understand the use of the attribute parameter.

Sorry if this is an obvious question or this is an inappropriate discussion topic but I did some research and wasn't finding any good resources on this topic. Anyway, as a recent convert from dataclasses, thank you for developing such an awesome package.

@hynek
Copy link
Member

hynek commented Sep 16, 2023

You can't pull value from self, because value isn't assigned to self until it has been validated. The attribute parameter allows you for certain meta programming things by, for instance, putting additional info into the meta field of an attribute and use that for validation. Adding a three-arg version of converters is in fact one of the most popular feature request ATM.

@hynek hynek closed this as completed Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants