X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/73cc0c58e7d9cd821216be6ea47159dece5398d3..875ef9a6250b27228ea7e8f0a02b9d6679de3e07:/pymin/validation.py 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()