def validate(self, data=None, from_flat=True):
        """Validate the form against the data passed.  If no data is provided
        the form data of the current request is taken.  By default a flat
        representation of the data is assumed.  If you already have a non-flat
        representation of the data (JSON for example) you can disable that
        with ``from_flat=False``.
        """
        if data is None:
            data = self._autodiscover_data()
        if from_flat:
            data = decode_form_data(data)
        self.raw_data = data

        # for each field in the root that requires validation on value
        # omission we add `None` into the raw data dict.  Because the
        # implicit switch between initial data and user submitted data
        # only happens on the "root level" for obvious reasons we only
        # have to hook the data in here.
        for name, field in self._root_field.fields.iteritems():
            if field.validate_on_omission and name not in self.raw_data:
                self.raw_data.setdefault(name)

        d = self.data.copy()
        d.update(self.raw_data)
        errors = {}
        try:
            data = self._root_field(d)
        except __HOLE__, e:
            errors = e.unpack(self)
        self.errors = errors

        # every time we validate, we invalidate the csrf token if there
        # was one.
        if self.csrf_protected:
            # FIXME: do we really want action here?
            invalidate_csrf_token(self._get_session(), self.action)

        if errors:
            return False

        self.data.update(data)
        return True

    # extra functionality that has to be implemented
dataset/ETHPy150Open mitsuhiko/fungiform/fungiform/forms.py/FormBase.validate