'Validate and possibly modify the field value before assignment'

def validate(self, value):

    if (self._type and (not isinstance(value, self._type))):
        raise TypeError((u'Expected    %s    to    be    a    %s,    not    %r' % (self._name, self._type, value)))
    if (self._choices and (value not in self._choices)):
        raise TypeError((u'Expected    %s    to    be    a    one    of    %s,    not    %r' % (self._name, self._choices, value)))
    return value
