SDK
SDK Jvm v1.x
2

validateSpecifications #

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

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


:::: tabs ::: tab Java

Arguments #

Copied to clipboard!
  public CompletableFuture<Map<String, Object>> validateSpecifications(
      final String index,
      final String collection,
      final Map<String, Object> specifications)

Arguments Type Description
index
String
Index name
collection
String
Collection name
specifications
Map<String, Object>
Specifications to validate

specifications #

A Map<String, Object> representing the specifications.

This object must follow the Specification Structure.

Returns #

Returns a Map<String, Object> which contains information about the specifications validity.

It contains the following properties:

Property Type Description
valid
Boolean
Specifications validity
details
ArrayList
Specifications errors
description
String
Global description of errors

Usage #

Copied to clipboard!
Map<String, Object> specifications = new HashMap<>();
Map<String, Object> fields = new HashMap<>();
Map<String, Object> license = new HashMap<>();
specifications.put("strict", false);
license.put("mandatory", true);
license.put("type", "symbol"); // type 'symbol' is not a recognized type
fields.put("license", license);
specifications.put("fields", fields);
Map<String, Object> result = kuzzle
  .getCollectionController()
  .validateSpecifications("nyc-open-data", "yellow-taxi", specifications)
  .get();
/*
  {
    valid=false,
    details=[
      "In nyc-open-data.yellow-taxi.license: symbol is not a recognized type."
    ],
    description="Some errors with provided specifications."
  }
*/

::: ::: tab Kotlin

Arguments #

Copied to clipboard!
fun validateSpecifications(
    index: String,
    collection: String,
    specifications: Map<String, Any>?
  ): CompletableFuture<Map<String, Any?>>

Arguments Type Description
index
String
Index name
collection
String
Collection name
specifications
Map<String, Any?>
Specifications to validate

specifications #

A Map<String, Any?> representing the specifications.

This object must follow the Specification Structure.

Returns #

Returns a Map<String, Any?> which contains information about the specifications validity.

It contains the following properties:

Property Type Description
valid
Boolean
Specifications validity
details
ArrayList
Specifications errors
description
String
Global description of errors

Usage #

Copied to clipboard!
val license: Map<String, Any> = HashMap<String, Any>().apply {
  put("type", "symbol")
  put("mandatory", true)
}
val fields: Map<String, Any> = HashMap<String, Any>().apply {
  put("license", license)
}
val specifications: Map<String, Any> = HashMap<String, Any>().apply {
  put("strict", false)
  put("fields", fields)
}
val result = kuzzle
  .collectionController
  .validateSpecifications("nyc-open-data", "yellow-taxi", specifications)
  .get()

::: ::::