Skip to content

Latest commit

 

History

History
63 lines (55 loc) · 1.25 KB

types.md

File metadata and controls

63 lines (55 loc) · 1.25 KB

Types

The type system is based on the following primitives:

There are two collection types:

And two special types:

New types can be defined using a combination of these core types and constraints.
Examples:

{
	...
	"types": {
		"integer": "number[numbers.integer]",
		"positive": "number[numbers.positive]",
		"longstring": "string[strings.minLength 150]",
		"state": "string[enum on off]"
	}
}

Generics

The collection types can have a generic constraint:

{
	...
	"types": {
		"strings": "list<string>",
		"longstrings": "list<string[strings.minLength 150]>",
		"numbers": "map<number>",
		"floats": "map<number[numbers.float]>"
	}

Structs

A map that has a specific set of keys, but the definition is different:

{
	...
	"types": {
		"name": "string[strings.between 2 15]",
		"user": {
			"id": "string[strings.exactLength 32]"
			"username": "string[strings.between 5 20]",
			"name": {
				"first": "name",
				"last": "name"
			}
		}
	}