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)
Argument | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
document | string | Document body |
options | types.QueryOptions | A struct containing query options |
options #
Additional query options
Option | Type (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")
}
Edit this page on Github(opens new window)