

def _do_validate(self, value):
    'Call all validations on the value.\n\n    This calls the most derived _validate() method(s), then the custom\n    validator function, and then checks the choices.  It returns the\n    value, possibly modified in an idempotent way, or raises an\n    exception.\n\n    Note that this does not call all composable _validate() methods.\n    It only calls _validate() methods up to but not including the\n    first _to_base_type() method, when the MRO is traversed looking\n    for _validate() and _to_base_type() methods.  (IOW if a class\n    defines both _validate() and _to_base_type(), its _validate()\n    is called and then the search is aborted.)\n\n    Note that for a repeated Property this function should be called\n    for each item in the list, not for the list as a whole.\n    '
    if isinstance(value, _BaseValue):
        return value
    value = self._call_shallow_validation(value)
    if (self._validator is not None):
        newvalue = self._validator(self, value)
        if (newvalue is not None):
            value = newvalue
    if (self._choices is not None):
        if (value not in self._choices):
            raise datastore_errors.BadValueError(('Value %r for property %s is not an allowed choice' % (value, self._name)))
    return value

dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/ndb/model.py Property._do_validate/original