From 875ef9a6250b27228ea7e8f0a02b9d6679de3e07 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Tue, 24 Jun 2008 00:11:06 -0300 Subject: [PATCH] Improve and document UpOneOf validator (refs #20) --- pymin/validation.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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() -- 2.43.0