public function validate($class, $data, $mode, $throwException = false, array $options = [])
    {
        $schema = $this->serializer->getSchema($class);

        //schema isn't always there yet
        if ($schema) {
            $validator = Validator::buildDefault();
            $errors = $validator->validate($this->toObject($data), $schema, '', [$mode]);

            if (!empty($errors) && $throwException) {
                throw new InvalidDataException(
                    sprintf('Invalid data for "%s".', $class),
                    $errors
                );
            }

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

        //validate uniques
        try {
            $validator = $this->get($class);
        } catch (\Exception $e) {
            //no custom validator
            $uniqueFields = [];
            $identifiers = $this->serializer->getIdentifiers($class);

            foreach ($identifiers as $identifier) {
                $uniqueFields[$identifier] = $identifier;
            }

            return $this->validateUnique($uniqueFields, $data, $mode, $class);
        }

        //can be deduced from the mapping, but we won't know
        //wich field is related to wich data prop in that case
        $uniqueFields = $validator->getUniqueFields();
        $errors = $this->validateUnique($uniqueFields, $data, $mode, $class);

        //custom validation
        $errors = array_merge($errors, $validator->validate($data, $mode, $options));

        if (!empty($errors) && $throwException) {
            throw new InvalidDataException(
                sprintf('Invalid data for "%s".', $class),
                $errors
            );
        }

        return $errors;
    }