public function validate($data, $options = []) {
        if (is_bool($options)) {
            trigger_error('The $sparse parameter is deprecated. Use [\'sparse\' => true] instead.', E_USER_DEPRECATED);
            $options = ['sparse' => true];
        }
        $options += ['sparse' => false];


        list($schema, $schemaPath) = $this->lookupSchema($this->schema, '');
        $field = new ValidationField($this->createValidation(), $schema, '', $schemaPath, $options);

        $clean = $this->validateField($data, $field);

        if (Invalid::isInvalid($clean) && $field->isValid()) {
            // This really shouldn't happen, but we want to protect against seeing the invalid object.
            $field->addError('invalid', ['messageCode' => 'The value is invalid.']);
        }

        if (!$field->getValidation()->isValid()) {
            throw new ValidationException($field->getValidation());
        }

        return $clean;
    }