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

Comments

Projects
None yet
4 participants
@leebenson
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

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 modified the milestones: 1.2, 1.3 Mar 26, 2018

Flargebla added a commit to Flargebla/cerberus that referenced this issue Jun 3, 2018

Addressed Issue pyeve#320, Expanded upon Custom Validators and linked…
… to validator rule docs to improve clarity

nicolaiarocci added a commit that referenced this issue Jun 11, 2018

@nicolaiarocci nicolaiarocci modified the milestones: 1.3, 1.2.1 Jun 11, 2018

nicolaiarocci added a commit that referenced this issue Jun 12, 2018

funkyfuture added a commit that referenced this issue Jan 27, 2019

Addressed Issue #320, Expanded upon Custom Validators and linked to v…
…alidator rule docs to improve clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.