Support nested field.
348185
def _from_nested_schema(self, obj, field):
        """"""
        if isinstance(field.nested, basestring):
            nested = get_class(field.nested)
        else:
            nested = field.nested

        name = nested.__name__
        outer_name = obj.__class__.__name__
        only = field.only
        exclude = field.exclude

        # If this is not a schema we've seen, and it's not this schema,
        # put it in our list of schema defs
        if name not in self._nested_schema_classes and name != outer_name:
            wrapped_nested = self.__class__(nested=True)
            wrapped_dumped = wrapped_nested.dump(
                nested(only=only, exclude=exclude)
            )

            # Handle change in return value type between Marshmallow
            # versions 2 and 3.
            if marshmallow.__version__.split('.', 1)[0] >= '3':
                self._nested_schema_classes[name] = wrapped_dumped
            else:
                self._nested_schema_classes[name] = wrapped_dumped.data
            self._nested_schema_classes.update(
                wrapped_nested._nested_schema_classes
            )

        # and the schema is just a reference to the def
        schema = {
            'type': 'object',
            '$ref': '#/definitions/{}'.format(name)
        }

        # NOTE: doubled up to maintain backwards compatibility
        metadata = field.metadata.get('metadata', {})
        metadata.update(field.metadata)

        for md_key, md_val in metadata.items():
            if md_key == 'metadata':
                continue
            schema[md_key] = md_val

        if field.many:
            schema = {
                'type': ["array"] if field.required else ['array', 'null'],
                'items': schema,
            }

        return schema
1038190
def add_field(self, field):
        """"""
        self.remove_field(field.name)
        self._fields[field.name] = field

        if field.default is not None:
            if six.callable(field.default):
                self._default_callables[field.key] = field.default
            else:
                self._defaults[field.key] = field.default
779776
def field_from_json(self, key_and_type, json_value):
        """"""
        assert ':' in key_and_type
        key, type_code = key_and_type.split(':', 1)
        from_json = self.field_function(type_code, 'from_json')
        value = from_json(json_value)
        return key, value
19885
def separate_fields(fields):
    
    flat_fields = {}
    nested_fields = {}

    # exclude "id" and "meta" elements
    for k, v in fields.items():
        # TODO: remove dependence on KEYS_TO_INCLUDE
        if k not in KEYS_TO_EXCLUDE:
            if type(v) not in [type({}), type([])]:
                flat_fields.update({k: v})
            else:
                nested_fields.update({k: v})

    return flat_fields, nested_fields
65706
def to_representation(self, value):
        """"""
        value = apply_subfield_projection(self, value, deep=True)
        return super().to_representation(value)
1170104
def set_field(self, name, value):
        """"""
        f = getattr(self, name, None)
        if isinstance(f, DataField):
            f.set(self, value)
        else:
            raise FieldError("No field named '%s'" % name)
1038023
def validate_field(field, allowed_keys, allowed_types):
    """"""
    for key, value in field.items():
        if key not in allowed_keys:
            raise exceptions.ParametersFieldError(key, "property")
        if key == defs.TYPE:
            if value not in allowed_types:
                raise exceptions.ParametersFieldError(value, key)
        if key == defs.VALUE:
            if not is_valid_field_name(value):
                raise exceptions.ParametersFieldError(value, "field name")
638743
function setNestedValue(data, field, value) {
        var fieldParts = _.isArray(field) ? field : field.split('.');

        // if no nesting, just set the value
        if (fieldParts.length === 1) {
            data[field] = _.isString(value) ? value.trim() : value;
            return;
        }

        // make sure the parent value exists
        data[fieldParts[0]] = data[fieldParts[0]] || {};

        // recursively call to go down a level
        setNestedValue(data[fieldParts[0]], fieldParts.slice(1, fieldParts.length), value);
    }
575610
def field(self, name, fieldType="C", size="50", decimal=0):
        """"""
        self.fields.append((name, fieldType, size, decimal))
554978
def _fmt_fields(fld_vals, fld2fmt):
    """"""
    vals = []
    for fld, val in fld_vals:
        if fld in fld2fmt:
            val = fld2fmt[fld].format(val)
        vals.append(val)
    return vals
1126783
def get_field(self, field_name, args, kwargs):
        """"""
        try:
            obj, arg_used = super(FormatterWrapper, self).get_field(
                    field_name, args, kwargs)
        except (KeyError, IndexError, AttributeError):
            if not self.tolerant:
                raise

            obj = MissingField(field_name)
            arg_used = field_name

        return obj, arg_used
416952
def bind_fields_to_model_cls(cls, model_fields):
        """"""
        return dict(
            (field.name, field.bind_model_cls(cls)) for field in model_fields)
1359300
def to_match(self):
        """"""
        template = u'({field_name} BETWEEN {lower_bound} AND {upper_bound})'
        return template.format(
            field_name=self.field.to_match(),
            lower_bound=self.lower_bound.to_match(),
            upper_bound=self.upper_bound.to_match())
907779
def multifield(self):
        """"""
        return bool(lib.EnvDeftemplateSlotMultiP(
            self._env, self._tpl, self._name))
412449
def _parse_request(self, schema, req, locations):
        """"""
        if schema.many:
            assert (
                "json" in locations
            ), "schema.many=True is only supported for JSON location"
            # The ad hoc Nested field is more like a workaround or a helper,
            # and it servers its purpose fine. However, if somebody has a desire
            # to re-design the support of bulk-type arguments, go ahead.
            parsed = self.parse_arg(
                name="json",
                field=ma.fields.Nested(schema, many=True),
                req=req,
                locations=locations,
            )
            if parsed is missing:
                parsed = []
        else:
            argdict = schema.fields
            parsed = {}
            for argname, field_obj in iteritems(argdict):
                if MARSHMALLOW_VERSION_INFO[0] < 3:
                    parsed_value = self.parse_arg(argname, field_obj, req, locations)
                    # If load_from is specified on the field, try to parse from that key
                    if parsed_value is missing and field_obj.load_from:
                        parsed_value = self.parse_arg(
                            field_obj.load_from, field_obj, req, locations
                        )
                        argname = field_obj.load_from
                else:
                    argname = field_obj.data_key or argname
                    parsed_value = self.parse_arg(argname, field_obj, req, locations)
                if parsed_value is not missing:
                    parsed[argname] = parsed_value
        return parsed
770352
def validateField(self, field) :
        """"""
        if field not in self.validators and not self.collection._validation['allow_foreign_fields'] :
            raise SchemaViolation(self.collection.__class__, field)

        if field in self.store:
            if isinstance(self.store[field], DocumentStore) :
                return self[field].validate()
            
            if field in self.patchStore :
                return self.validators[field].validate(self.patchStore[field])
            else :
                try :
                    return self.validators[field].validate(self.store[field])
                except ValidationError as e:
                    raise ValidationError( "'%s' -> %s" % ( field, str(e)) )
                except AttributeError:
                    if isinstance(self.validators[field], dict) and not isinstance(self.store[field], dict) :
                        raise ValueError("Validator expected a sub document for field '%s', got '%s' instead" % (field, self.store[field]) )
                    else :
                        raise
        return True
344925
private static Field findFieldInHierarchy(Object object, String fieldName) {
        return findFieldInHierarchy(object, new FieldNameMatcherStrategy(fieldName));
    }