SDK
SDK Javascript v6.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 or modify the existing specification.

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


validateSpecifications(index, collection, specifications, [options]);

ArgumentsTypeDescription
index
string
Index name
collection
string
Collection name
specifications
object
Specifications to validate
options
object
Query options

specifications #

An object representing the specifications.

This object must follow the Specification Structure:

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

options #

Additional query options

PropertyType
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again

Resolves #

Resolves to an object which contain information about the specifications validity.

It contains the following properties:

PropertyTypeDescription
valid
boolean
Specifications validity
details
string[]
Specifications errors
description
string
Global description of errors

Usage #

try {
  const specifications = {
    strict: false,
    fields: {
      license: {
        mandatory: true,
        type: 'symbol' // symbol is not a recognized type
      }
    }
  };
  const result = await kuzzle.collection.validateSpecifications('nyc-open-data', 'yellow-taxi', specifications);
  console.log(result);
  /*
    {
      valid: false,
      details: [
        'In nyc-open-data.yellow-taxi.license: symbol is not a recognized type.'
      ],
      description: 'Some errors with provided specifications.'
    }
  */
  if (result.valid === false) {
    console.log(result.description);
  }
} catch (error) {
  console.error(error.message);
}