SDK
SDK Golang v3.x
2

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 #

ValidateSpecifications(index string, collection string, specifications json.RawMessage, options types.QueryOptions) (types.ValidationResponse, error)
ArgumentsTypeDescription
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:

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

options #

Additional query options

PropertyTypeDescriptionDefault
queuable
bool
Make this request queuable or nottrue

Return #

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

PropertyTypeDescription
ValidboolSpecification validity
Details
[]string
Details about each specification errors
DescriptionstringGeneral error message

Usage #

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