SDK
SDK C# v2.x
2

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 #

public async Task<bool> ValidateSpecificationsAsync(
        string index,
        string collection,
        JObject specifications);
ArgumentTypeDescription
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:

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

Return #

A boolean telling whether the provided specifications are valid.

Usage #

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);
}