validate

Validates data against existing validation rules.

Note that if no validation specifications are set for the <index>/<collection>, the document will always be valid.

This request does not store or publish the document.

Arguments

Copied to clipboard!
boolean validate(String index, String collection, String document)

boolean validate(
  String index,
  String collection,
  String document,
  io.kuzzle.sdk.QueryOptions options
)

Argument Type Description
index
String
Index name
collection
String
Collection name
body
String
A JSON string containing the body of the document
options
io.kuzzle.sdk.QueryOptions
Query options

options

Additional query options

Option Type
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again

Return

Returns a boolean value set to true if the document is valid and false otherwise.

Exceptions

Throws a io.kuzzle.sdk.KuzzleException if there is an error. See how to handle error.

Usage

Copied to clipboard!
String doc = "{\"capacity\": 4}";

try {
  boolean valid = kuzzle.getDocument().validate("nyc-open-data", "yellow-taxi", doc);

  if (valid) {
    System.out.println("Success");
  }
} catch (KuzzleException e) {
  System.err.println(e.getMessage());
}