RemoteStorage.BaseClient.Types

  • Manages and validates types of remoteStorage objects, using JSON-LD and JSON Schema
  • Adds schema declaration/validation methods to BaseClient instances.
Summary
RemoteStorage.BaseClient.Types
RemoteStorage.BaseClient
Functions
declareTypeDeclare a remoteStorage object type using a JSON schema.
validateValidate an object against the associated schema.

RemoteStorage.BaseClient

Summary
Functions
declareTypeDeclare a remoteStorage object type using a JSON schema.
validateValidate an object against the associated schema.

Functions

declareType

declareType: function(alias,
uri,
schema)

Declare a remoteStorage object type using a JSON schema.

Parameters

aliasA type alias/shortname
uri(optional) JSON-LD URI of the schema.  Automatically generated if none given
schemaA JSON Schema object describing the object type

Example

client.declareType('todo-item', {
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "finished": {
      "type": "boolean"
      "default": false
    },
    "createdAt": {
      "type": "date"
    }
  },
  "required": ["id", "title"]
})

Visit http://json-schema.org for details on how to use JSON Schema.

validate

validate: function(object)

Validate an object against the associated schema.

Parameters

objectObject to validate.  Must have a @context property.

Returns

An object containing information about validation errors

declareType: function(alias,
uri,
schema)
Declare a remoteStorage object type using a JSON schema.
validate: function(object)
Validate an object against the associated schema.
Close