code: def forTypes(klass, key, classes, description, extraValidator=None):
          
          fixedClasses = []
          for k in classes:
              if k is None:
                  k = type(None)
              if k not in _JSON_TYPES:
                  raise TypeError("%s is not JSON-encodeable" % (k, ))
              fixedClasses.append(k)
          fixedClasses = tuple(fixedClasses)
  
          def validate(value):
              if not isinstance(value, fixedClasses):
                  raise ValidationError(
                      value,
                      "Field %r requires type to be one of %s" % (key, classes))
              if extraValidator is not None:
                  extraValidator(value)
  
          return klass(key, lambda v: v, description, extraValidator=validate)
docs: Create a L{Field} that must be an instance of a given set of types.
  
          @param key: The name of the field, the key which refers to it,
              e.g. C{"path"}.
  
          @ivar classes: A C{list} of allowed Python classes for this field's
              values. Supported classes are C{unicode}, C{int}, C{float},
              C{bool}, C{long}, C{list} and C{dict} and C{None} (the latter
              isn't strictly a class, but will be converted appropriately).
  
          @param description: A description of what this field contains.
          @type description: C{unicode}
  
          @param extraValidator: See description in L{Field.__init__}.
  
          @return: A L{Field}.