Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel2
outlinefalse
typelist
printablefalse

What is JSON Schema?

Any valid JSON document has a specific structure of JSON fields and/or JSON arrays.

...

You can see, the JSON Schema defines four fields of different types: The firstName, lastName, age and gender of a person. So whenever a person JSON document is validated using this JSON Schema now, it must comply with exactly these rules. For example: In case such a person JSON document contains the attribute value age as string instead of a number, JSON Schema validation will fail.

Usage inside PIPEFORCE

In PIPEFORCE, a JSON Schema can be used mainly for these purposes:

  • To define the widgets of a form in a Form Schema → Any Form Schema is a valid JSON Schema.

  • To define the schema for list columns in a List Schema → Any List Schema is a valid JSON Schema.

  • To define the schema of custom JSON documents and validate them whenever required using the command json.validate.

In order to get a full documentation of the JSON Schema specification, you should go to the official website at: https://json-schema.org.

Form Schema

A Form Schema is a JSON Schema which defines the validation, type and structure rules of widgets inside a PIPEFORCE Form. For more details see: Form Schema & Widgets (Model).

List Schema

A List Schema is a JSON Schema which defines the columns of a table (list) of a PIPEFORCE List. For more details see: List Framework Lists.

Define and validate a JSON object

You can also use a JSON Schema in order to specify the structure of a given JSON document (object). PIPEFORCE provides built-in toolings for storage, resolving and validation using JSON Schemas.

For more details see: Validating Properties.

Schema attribute type

The type attribute inside a JSON schema defines the required data type of a JSON attribute. Possible values are:

...

Code Block
languagejson
{
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    },
    "age": {
      "type": "number"
    },
    "gender": {
      "type": "string",
      "enum": ["male", "female", "neutral"]
    }
  }
}

Schema attribute format

The format attribute can be used for more precise semantic specification of string types. For example you can define whether a string must be a valid email address or URL for example.

...

For a full list of built-in format types, see: https://json-schema.org/understanding-json-schema/reference/string.html#format

Schema Validation Rules

Below you can find some common validation rules in JSON Schema.

Length

Code Block
{
  "type": "string",
  "minLength": 2,
  "maxLength": 3
}

Valid: hi

Regular expression

Code Block
{
   "type": "string",
   "pattern": "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$"
}

Valid: 555-1212

Date and Time

Code Block
{
   "type": "string",
   "format": "date-time"
}

Valid: 2018-11-13T20:20:39+00:00

Time

Code Block
{
   "type": "string",
   "format": "time"
}

Valid: 20:20:39+00:00

Date

Code Block
{
   "type": "string",
   "format": "date"
}

Valid: 2018-11-13

Email

Code Block
{
   "type": "string",
   "format": "email"
}

Valid: my@email.de

Hostname

Code Block
{
   "type": "string",
   "format": "hostname"
}

Valid: google.com

Uri

Code Block
{
   "type": "string",
   "format": "uri"
}

Valid: https://google.com

Required fields

Code Block
{
  "type": "object",
  "properties": {
    "name":      { "type": "string" },
    "email":     { "type": "string" },
    "address":   { "type": "string" },
    "telephone": { "type": "string" }
  },
  "required": ["name", "email"]
}