SDK
SDK Golang v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

ValidateSpecifications #

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

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

Arguments #

Copied to clipboard!
ValidateSpecifications(index string, collection string, specifications json.RawMessage, options types.QueryOptions) (types.ValidationResponse, error)
Arguments Type Description
index
string
Index name
collection
string
Collection name
specifications
json.RawMessage
Collection data mapping in JSON format
options
QueryOptions
Query options

specifications #

A JSON representation of the specifications.

The JSON must follow the Specification Structure:

Copied to clipboard!
{
  "myindex": {
    "mycollection": {
      "strict": "<boolean>",
      "fields": {
        // ... specification for each field
      }
    }
  }
}

options #

Additional query options

Property Type Description Default
queuable
bool
Make this request queuable or not true

Return #

A types.ValidationResponse which contain information about the specifications validity.

Property Type Description
Valid bool Specification validity
Details
[]string
Details about each specification errors
Description string General error message

Usage #

Copied to clipboard!
specifications := json.RawMessage(`{ "strict": false, "fields": { "license": { "mandatory": true, "type": "string" } } }`)
vr, err := kuzzle.Collection.ValidateSpecifications("nyc-open-data", "yellow-taxi", specifications, nil)
if err != nil {
  log.Fatal(err)
} else if vr.Valid == true {
  fmt.Println("Success")
}