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

            if (count($errors) > 0) {
                return $errors; // todo : it should throw an Exception otherwise it makes return inconsistent
            }
        }

        // gets entity from raw data.
        $object = new $class();
        $object = $this->serializer->deserialize($data, $object, $options);

        // creates the entity if allowed
        $this->checkPermission('CREATE', $object, [], true);

        if ($this->dispatch('create', 'pre', [$object, $options])) {
            $this->om->save($object);
            if (!in_array(Options::IGNORE_CRUD_POST_EVENT, $options)) {
                $this->dispatch('create', 'post', [$object, $options]);
            }
        }

        return $object;
    }