Skip to content

SchemaEditor - Types and Formats

Text data of any length.

{
type: 'string'
}

Use for: Names, descriptions, text fields, IDs

Common formats:

  • date, time, date-time - Temporal data
  • email - Email addresses
  • uri - URLs and URIs
  • uuid - Unique identifiers

Numeric values, including decimals.

{
type: 'number'
}

Use for: Prices, measurements, percentages, coordinates

Validation options:

  • minimum / maximum - Range constraints
  • multipleOf - Must be multiple of value
{
type: 'number',
minimum: 0,
maximum: 100,
multipleOf: 0.01 // Two decimal places
}

Whole numbers only, no decimals.

{
type: 'integer'
}

Use for: Counts, quantities, IDs, ages, years

Validation options: Same as number

{
type: 'integer',
minimum: 0,
maximum: 150
}

True or false values.

{
type: 'boolean'
}

Use for: Flags, toggles, yes/no questions

Nested objects with their own properties.

{
type: 'object',
properties: {
street: { type: 'string' },
city: { type: 'string' },
zipCode: { type: 'string' }
},
required: ['street', 'city']
}

Use for: Complex structured data, nested entities

Additional options:

  • properties - Define nested properties
  • required - List of required property names
  • additionalProperties - Allow/disallow extra properties

Lists of items, all of the same type.

{
type: 'array',
items: { type: 'string' }
}

Use for: Lists, collections, tags, multiple selections

Validation options:

  • items - Schema for array elements
  • minItems / maxItems - Length constraints
  • uniqueItems - Require unique elements
{
type: 'array',
items: { type: 'string', format: 'email' },
minItems: 1,
maxItems: 5,
uniqueItems: true
}

Explicit null values.

{
type: 'null'
}

Use for: Optional fields that can be explicitly null

Often combined with other types:

{
type: ['string', 'null'] // Can be string or null
}

Full date in ISO 8601 format: YYYY-MM-DD

{ type: 'string', format: 'date' }
// Example: "2024-01-15"

Time of day: HH:MM:SS or HH:MM:SS.sss

{ type: 'string', format: 'time' }
// Example: "14:30:00"

Combined date and time with timezone: ISO 8601

{ type: 'string', format: 'date-time' }
// Example: "2024-01-15T14:30:00Z"

Email address format

{ type: 'string', format: 'email' }
// Example: "user@example.com"

UUID/GUID identifier

{ type: 'string', format: 'uuid' }
// Example: "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"

Uniform Resource Identifier

{ type: 'string', format: 'uri' }
// Example: "https://example.com/path"

DNS hostname

{ type: 'string', format: 'hostname' }
// Example: "www.example.com"

IPv4 address

{ type: 'string', format: 'ipv4' }
// Example: "192.168.1.1"

IPv6 address

{ type: 'string', format: 'ipv6' }
// Example: "2001:0db8:85a3:0000:0000:8a2e:0370:7334"

JSON Pointer reference

{ type: 'string', format: 'json-pointer' }
// Example: "/path/to/property"

Regular expression pattern

{ type: 'string', format: 'regex' }
// Example: "^[a-zA-Z0-9]+$"

In SchemaEditor:

  1. Type = string: All formats available
  2. Type = number/integer: No formats (formats are for strings)
  3. Type = boolean/null: No formats
  4. Type = object/array: No formats (structure defines validation)

Extend with custom format validators:

const customFormats = {
'phone': /^\+?[1-9]\d{1,14}$/,
'postal-code': /^[A-Z0-9]{3,10}$/,
'credit-card': /^\d{13,19}$/
};

Register custom formats with your JSON schema validator library.

DataRecommended TypeFormat
Person namestring-
Email addressstringemail
Birth datestringdate
Created timestampstringdate-time
User IDstringuuid
Ageinteger-
Pricenumber-
Quantityinteger-
Is activeboolean-
Tagsarray of string-
Addressobject-
Settingsobject-
Phone numberstringcustom: phone

When changing a property’s type in SchemaEditor:

  • string → number: Existing string values must be numeric
  • number → integer: Decimals will be truncated
  • any → array: Wraps value in array
  • any → object: Creates object with original value
  • array/object → primitive: May lose data

Always validate data after type changes.