ValidateSpecificationsAsync

The validateSpecifications method checks if validation specifications are well-formed. It does not store nor modify the existing specifications.

If the validation specifications are not formatted correctly, a detailed error message is returned to help with debugging.

Arguments

Copied to clipboard!
public async Task<bool> ValidateSpecificationsAsync(
        string index,
        string collection,
        JObject specifications);
Argument Type Description
index
string
Index name
collection
string
Collection name
specifications
JObject
JObject representating the specifications to validate

specifications

A JObject representing the specifications to validate.

The JObject data must follow the Specifications Structure:

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

Return

A boolean telling whether the provided specifications are valid.

Usage

Copied to clipboard!
try {
  JObject specifications = JObject.Parse(@"{
    strict: false,
    fields: {
      license: {
        mandatory: true,
        type: 'string'
      }
    }
  }");
  bool validation_response =
    await kuzzle.Collection.ValidateSpecificationsAsync(
      "nyc-open-data",
      "yellow-taxi",
      specifications);
  Console.WriteLine("Success");
} catch (Exception e) {
  Console.WriteLine(e);
}