Skip to content
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

Incorrect validator docs #320

Closed
leebenson opened this issue Jun 27, 2017 · 5 comments
Closed

Incorrect validator docs #320

leebenson opened this issue Jun 27, 2017 · 5 comments
Milestone

Comments

@leebenson
Copy link

@leebenson leebenson commented Jun 27, 2017

I spent about an hour trying to implement a custom validator per http://docs.python-cerberus.org/en/stable/customize.html, and finally realised that the docs are wrong!

This:

class MyValidator(Validator):
    def _validate_isodd(self, isodd, field, value):

should be:

class MyValidator(Validator):
    def _validator_isodd(self, isodd, field, value):

i.e. _validate_ -> _validator_

@funkyfuture
Copy link
Member

@funkyfuture funkyfuture commented Jun 27, 2017

disclaimer: i might be wrong as i'm quiet tired.

the _validate_-prefix is used for custom rules (isodd in the example) while _validator_ is for the validator rule (which doesn't require to subclass Validator, but does't allow to define constraints in schemas). if i'm not wrong, it nonetheless raises the point that the documentation should be more verbose on that difference. contributions in this regard are highly appreciated!

@leebenson
Copy link
Author

@leebenson leebenson commented Jun 28, 2017

Thanks - makes sense @funkyfuture. I agree that the docs could do with a clarification- it definitely wasn't obvious to me that _validator_ and _validate_ were two different concepts.

@funkyfuture
Copy link
Member

@funkyfuture funkyfuture commented Aug 19, 2017

i pledge to mark this for the 1.2 milestone.

@nicolaiarocci nicolaiarocci added this to the 1.2 milestone Aug 20, 2017
@bryanwweber
Copy link
Contributor

@bryanwweber bryanwweber commented Sep 30, 2017

FWIW, I also asked a question on StackOverflow about this topic: https://stackoverflow.com/q/39438774/2449192 @nicolaiarocci Answered me there as well, but I didn't quite understand his answer.

@funkyfuture
Copy link
Member

@funkyfuture funkyfuture commented Sep 30, 2017

@bryanwweber, i edited Nicola's answer yesterday or the day before to point a major difference. i notice, i should amend an example (put a link to one now). if there's still clarification needed, please let us know.

one thought: maybe we shouldn't talk of 'custom validators', there are no standard ones, so custom rule vs. validator.

@nicolaiarocci nicolaiarocci removed this from the 1.2 milestone Mar 26, 2018
@nicolaiarocci nicolaiarocci added this to the 1.3 milestone Mar 26, 2018
Flargebla added a commit to Flargebla/cerberus that referenced this issue Jun 3, 2018
… to validator rule docs to improve clarity
nicolaiarocci added a commit that referenced this issue Jun 11, 2018
@nicolaiarocci nicolaiarocci removed this from the 1.3 milestone Jun 11, 2018
@nicolaiarocci nicolaiarocci added this to the 1.2.1 milestone Jun 11, 2018
nicolaiarocci added a commit that referenced this issue Jun 12, 2018
…or_rule_#409'

Addresses #320 and #403
funkyfuture added a commit that referenced this issue Jan 27, 2019
…alidator rule docs to improve clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants