SDK
SDK C# v2.x
2

ValidateAsync #

Validates data against existing validation rules.

Documents are always valid if no validation rules are defined on the provided index and collection.

This request does not store the document.

Arguments #

public async Task<bool> ValidateAsync(
  string index, 
  string collection, 
  JObject content);

ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
content
JObject
JObject representing the document

Return #

A bool set to true if the document is valid and false otherwise.

Exceptions #

Throws a KuzzleException if there is an error. See how to handle errors.

Usage #

try {
  bool valid = await kuzzle.Document.ValidateAsync(
    "nyc-open-data",
    "yellow-taxi",
    JObject.Parse(@"{
      ""capacity"": 4
    }"));
  if (valid) {
    Console.WriteLine("The document is valid");
  }
} catch (KuzzleException e) {
  Console.Error.WriteLine(e);
}