SDK
SDK Golang v2.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.

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 #

Validate(
  index string,
  collection string,
  document json.RawMessage,
  options types.QueryOptions) (bool, error)

ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
document
string
Document body
options
types.QueryOptions
A struct containing query options

options #

Additional query options

OptionType
(default)
Description
Queuable
bool

(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.

Usage #

isValid, err := kuzzle.Document.Validate(
  "nyc-open-data",
  "yellow-taxi",
  json.RawMessage(`{
    "capacity": 4
  }`),
  nil)
if err != nil {
  log.Fatal(err)
} else if isValid {
  fmt.Println("Success")
}