public function update($class, $data, array $options = [])
    {
        // validates submitted data.
        if (!in_array(self::NO_VALIDATE, $options)) {
            $errors = $this->validate($class, $data, ValidatorProvider::UPDATE);

            if (count($errors) > 0) {
                return $errors;
            }
        }

        $oldObject = $this->om->getObject($data, $class) ?? new $class();
        $this->checkPermission('EDIT', $oldObject, [], true);
        $oldData = $this->serializer->serialize($oldObject);

        if (!$oldData) {
            $oldData = [];
        }

        $object = $this->serializer->deserialize($data, $oldObject, $options);

        if ($this->dispatch('update', 'pre', [$object, $options, $oldData])) {
            $this->om->save($object);
            $this->dispatch('update', 'post', [$object, $options, $oldData]);
        }

        return $object;
    }