SDK
SDK C++ v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

This SDK has been deprecated because of stability issues. It is not advised to use it in a production environment.

validateSpecifications #

The validateSpecifications method checks if a validation specification is well formatted. It does not store nor modify the existing specification.

When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug.

Signature #

kuzzleio::validation_response* validateSpecifications(
    const std::string& index,
    const std::string& collection,
    const std::string& specifications);

kuzzleio::validation_response* validateSpecifications(
    const std::string& index,
    const std::string& collection,
    const std::string& specifications,
    const kuzzleio::query_options& options);

Arguments #

ArgumentsTypeDescription
indexconst std::string&Index name
collectionconst std::string&Collection name
specificationsconst std::string&JSON string representating the specifications to validate
optionskuzzleio::query_options\*Query options

specifications #

A JSON string representing the specifications the specifications.

The JSON must follow the Specification Structure:

{
  "strict": "true",
  "fields": {
    "licence": {
      "mandatory": true,
      "type": "string"
    }
    // ... specification for each field
  }
}

options #

Additional query options

PropertyType
(default)
Description
queuablebool(true)If true, queues the request during downtime, until connected to Kuzzle again

Return #

A kuzzleio::validation_response object which contain information about the specifications validity.

PropertyTypeDescription
validboolSpecification validity
detailsconst char \* const \*Array of string with details about each specification errors
descriptionconst char \*General error message

Usage #

try {
  std::string specifications = R"({
    "strict": false,
    "fields": {
      "license": {
        "mandatory": true,
        "type": "string"
      }
    }
  })";
  kuzzleio::validation_response *validation_response =
    kuzzle->collection->validateSpecifications(
      "nyc-open-data",
      "yellow-taxi",
      specifications);
  if (validation_response->valid) {
    std::cout << "Specifications are valid" << std::endl;
  }
} catch (kuzzleio::KuzzleException &e) {
  std::cerr << e.what() << std::endl;
}