Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rename acceptable to choices

  • Loading branch information...
commit ccbb3c4dff2ff97327f90c7aaa5191ba42353a6c 1 parent 02f81f2
Chris McDonough mcdonc authored
Showing with 8 additions and 6 deletions.
  1. +7 −5 colander/__init__.py
  2. +1 −1  colander/tests/test_colander.py
12 colander/__init__.py
View
@@ -360,19 +360,21 @@ def __call__(self, node, value):
class ContainsOnly(object):
""" Validator which succeeds if the value passed to is a sequence and each
- element in the sequence is also in the sequence passed as ``acceptable``
+ element in the sequence is also in the sequence passed as ``choices``.
+ This validator is useful when attached to a schemanode with, e.g. a
+ :class:`colander.Set` or another sequencetype.
"""
err_template = _(
'One or more of the choices you made was not acceptable'
)
- def __init__(self, acceptable):
- self.acceptable = set(acceptable)
+ def __init__(self, choices):
+ self.choices = choices
def __call__(self, node, value):
- if not set(value).issubset(self.acceptable):
+ if not set(value).issubset(self.choices):
err = _(
self.err_template,
- mapping = {'val':value, 'acceptable':self.acceptable}
+ mapping = {'val':value, 'choices':self.choices}
)
raise Invalid(node, err)
2  colander/tests/test_colander.py
View
@@ -428,7 +428,7 @@ def test_failure(self):
def test_failure_with_custom_error_template(self):
validator = self._makeOne([1])
from colander import _
- validator.err_template = _('${val}: ${acceptable}')
+ validator.err_template = _('${val}: ${choices}')
e = invalid_exc(validator, None, [2])
self.assertTrue('[2]' in e.msg.interpolate())
Please sign in to comment.
Something went wrong with that request. Please try again.