Examples
The Data Schema is the essence of your Object Type. Created using JSON, Data Schemas can be as simple or complex as your needs demand. Several examples of this powerful Contextual capability are provided.
An example of a Customer Object Type typical to a simple business or CRM system.
| Object Type Definition | Value |
|---|---|
| ID | customer |
| Display Name | Customer |
| Display Name (Plural) | Customers |
| Description | Customers of my company. |
| Category | Data |
{
"primaryKey": "customerId",
"type": "object",
"properties": {
"customerId": {
"type": "string",
"generate": {
"type": "uuid",
"format": "v4"
}
},
"firstName": {
"type": "string",
"minLength": 1
},
"lastName": {
"type": "string",
"minLength": 1
},
"email": {
"type": "string",
"format": "email",
"minLength": 1
},
"phone": {
"type": "string",
"minLength": 1
},
"address": {
"type": "object",
"properties": {
"street": {
"type": "string",
"minLength": 1
},
"city": {
"type": "string",
"minLength": 1
},
"state": {
"type": "string",
"minLength": 1
},
"zip": {
"type": "string",
"minLength": 1
}
},
"required": [
"street",
"city",
"state",
"zip"
]
}
},
"required": [
"firstName",
"lastName",
"email",
"phone",
"address"
],
"additionalProperties": false
}
This schema defines an object for storing customer data, using customerId as the primary key, which is generated as a UUID version 4 string. The schema includes properties such as firstName, lastName, email (which must be a valid email format), and phone, each requiring a minimum length of one character. It also details an address object with mandatory properties like street, city, state, and zip, each also requiring a minimum length of one. All these properties are required for the object to be valid. Additionally, the schema disallows any properties not explicitly defined (additionalProperties is set to false).
An example of an Invoice Object Type, typical to a simple business or CRM system.
| Object Type Definition | Value |
|---|---|
| ID | invoice |
| Display Name | Invoice |
| Display Name (Plural) | Invoices |
| Description | Invoices for my services. |
| Category | Data |
{
"primaryKey": "invoiceId",
"type": "object",
"properties": {
"invoiceId": {
"type": "string",
"generate": {
"type": "uuid",
"format": "v4"
}
},
"clientName": {
"type": "string",
"minLength": 1
},
"clientAddress": {
"type": "object",
"properties": {
"street": {
"type": "string",
"minLength": 1
},
"city": {
"type": "string",
"minLength": 1
},
"state": {
"type": "string",
"minLength": 1
},
"zip": {
"type": "string",
"minLength": 1
}
},
"required": [
"street",
"city",
"state",
"zip"
]
},
"consultantName": {
"type": "string",
"minLength": 1
},
"date": {
"type": "string",
"format": "date"
},
"hours": {
"type": "number",
"minimum": 1
},
"hourlyRate": {
"type": "number",
"minimum": 1
},
"totalAmount": {
"type": "number",
"minimum": 1
},
"status": {
"type": "string",
"enum": [
"draft",
"sent",
"paid",
"overdue"
]
}
},
"required": [
"clientName",
"clientAddress",
"consultantName",
"date",
"hours",
"hourlyRate",
"totalAmount",
"status"
],
"additionalProperties": false
}
This schema defines an object for an invoice, using invoiceId as the primary key, which is generated as a UUID version 4 string. It includes properties such as clientName, clientAddress (an embedded object with required properties like street, city, state, and zip), consultantName, date (in date format), hours (a number with a minimum of 1), hourlyRate (also a number with a minimum of 1), totalAmount (a number with a minimum of 1), and status (restricted to "draft", "sent", "paid", or "overdue"). All properties listed are required, and no additional properties are allowed outside those defined.
An example of a ZIP Code Object Type which could be used to store a record of every ZIP Code in the United States, and associated geo-location information.
| Object Type Definition | Value |
|---|---|
| ID | zipcode |
| Display Name | ZIP Code |
| Display Name (Plural) | ZIP Codes |
| Description | ZIP Codes throughout the United States. |
| Category | Setting |
{
"primaryKey": "zipCode",
"type": "object",
"properties": {
"zipCode": {
"description": "Postal code",
"type": "string",
"pattern": "^\\d{5}(?:[-\\s]\\d{4})?$"
}
},
"required": [
"zipCode"
],
"additionalProperties": false
}
This schema defines an object that primarily uses zipCode as its unique identifier. The zipCode is a required property, characterized by the type "string" and must follow a specific pattern. The acceptable format for the zipCode is either a five-digit number or a five-digit number followed by a dash or space and then four additional digits (e.g., 12345 or 12345-6789). The schema restricts any properties other than those explicitly defined (additionalProperties is set to false), emphasizing that the only data this schema will accept pertains to the zipCode.
An example of a Freeform Object Type which simply creates a unique ID and records any valid JSON properties and values that are provided.
| Object Type Definition | Value |
|---|---|
| ID | freeform |
| Display Name | Freeform |
| Display Name (Plural) | Freeform |
| Description | Uniquely identified records of various schema shapes. |
| Category | Data |
{
"primaryKey": "id",
"type": "object",
"properties": {
"id": {
"type": "string",
"generate": {
"type": "uuid",
"format": "v4"
}
}
}
}
This schema defines a simple object where the primary key is id. The id is a string that is automatically generated as a UUID version 4. The schema specifies only this one property, focusing solely on the identifier for the object. Notably, the schema does not restrict additional properties, meaning it will allow any data posted to be processed alongside the id.