From: Leandro Lucarella Date: Tue, 24 Jun 2008 03:11:06 +0000 (-0300) Subject: Improve and document UpOneOf validator (refs #20) X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/875ef9a6250b27228ea7e8f0a02b9d6679de3e07 Improve and document UpOneOf validator (refs #20) --- diff --git a/pymin/validation.py b/pymin/validation.py index a9baf22..ea31c1d 100644 --- a/pymin/validation.py +++ b/pymin/validation.py @@ -8,7 +8,22 @@ from pymin.item import Item from pymin.validatedclass import Field class UpOneOf(OneOf): - "Same as :class:`OneOf` but values are uppercased before validation." - def validate_python(self, value, state): - return OneOf.validate_python(self, value.upper(), state) + """ + Same as :class:`OneOf` but values are uppercased before validation. + + Examples:: + + >>> uoo = UpOneOf(['A', 'B', 'C']) + >>> uoo.to_python('a') + 'A' + >>> uoo.to_python('B') + 'B' + >>> uoo.to_python('x') + Traceback (most recent call last): + ... + Invalid: Value must be one of: A; B; C (not 'X') + """ + + def _to_python(self, value, state): + return value.upper()