Kizaki
ReferenceInspire

Types, Enums, And Embedded Types

Scalar types, field annotations, enums, and embedded types in the Inspire language.

Scalar Types

TypePostgreSQLNotes
stringtextUse @maxLength(n) instead of varchar
intinteger
smallintsmallint
bigintbigint
decimal(p, s)numeric(p, s)Precision and scale required
doubledouble precision
booleanboolean
datetimetimestamptzAlways with timezone
datedate
uuiduuidDefault primary key type
bytesbytea
jsonjsonbUntyped; prefer embedded types when shape is known
filejsonbFile metadata; see Files And Network

Nullable, Default, And Array

entity Example {
  required: string,            // required by default
  optional: string?,           // nullable with ?
  withDefault: boolean = false, // inline default value
  tags: string[],              // array type with []
  scores: int[],
}

Arrays of embedded types and json compile to jsonb. Nested arrays (type[][]) are not supported.

Field Annotations

Constraints

AnnotationDescription
@uniqueUNIQUE constraint on the column
@primaryKeyUse as the primary key
@onDelete(cascade|restrict|setNull)FK delete behavior

String Validation

AnnotationDescription
@minLength(n)Minimum character count
@maxLength(n)Maximum character count
@regex("pattern")Must match regex
@emailMust be valid email format
@urlMust be valid URL format
@trimStrip leading/trailing whitespace before saving

Numeric Validation

AnnotationDescription
@min(n)Minimum value
@max(n)Maximum value

File Validation

AnnotationDescription
@maxSize(n)Maximum file size in bytes. Rejected at upload time if the declared size exceeds this limit.
@accept("mime/types")Comma-separated MIME type patterns. Supports wildcards (e.g., "image/*,application/pdf"). Rejected at upload time if the MIME type does not match.

Valid only on file fields. Enforced when a presigned upload URL is requested.

Data Protection

AnnotationDescription
@sensitiveApplication-level encryption at rest (AES-256-GCM)
@piiPersonally identifiable information — values are replaced with [PII:field_name] in structured logs. Log safety only, not encryption. Use @sensitive for encryption at rest.
@index(equality)HMAC blind index for exact-match queries on @sensitive fields

Validation annotations (@minLength, @maxLength, @min, @max, @regex, @email, @url, @maxSize, @accept) are enforced on every insert, update, or file upload request.

Other

AnnotationDescription
@indexCreate a B-tree index on the column

Entity-Level Annotations

These appear inside the entity body but apply to the entity as a whole.

AnnotationDescription
@unique([f1, f2])Composite unique constraint
@index([f1, f2])Composite index
@primaryKey([f1, f2])Composite primary key
@suppress([W0001])Suppress specific compiler warnings
@systemMarks as a system-managed entity
@noDefaultsExclude from the defaults {} block

Enums

An enum defines a closed set of named values. The compiler generates a PostgreSQL ENUM type.

enum ProjectStatus {
  Draft,
  Active,
  Archived,
}

enum TeamRole {
  Member,
  Admin,
  Owner,
}

Use enum names as field types:

entity Project {
  status: ProjectStatus,
  archivedAt: datetime?,
}

Use enum values in policy conditions:

entity Project {
  status: ProjectStatus,

  @grant read to @public where resource.status == Active
}

Embedded Types

An embedded type declares a typed shape stored as a jsonb column. Embedded types have no separate table, no id, no created_at/updated_at, no policies, and no foreign keys.

embedded type Address {
  street: string,
  city: string,
  state: string @maxLength(2),
  zip: string,
  country: string = "US",
}

embedded type Preferences {
  theme: string = "light",
  notifications: boolean = true,
}

Use embedded types as field types on entities:

entity User {
  name: string,
  address: Address?,
  preferences: Preferences = Preferences{},
  shippingAddresses: Address[],
}

Preferences = Preferences{} defaults to a JSONB object with all field defaults filled in. Embedded types can be nested and used in arrays.

Use embedded types for value objects with no independent identity — addresses, settings, metadata blobs. Use entities when you need id, policies, or relations.

Related guides: Build Your First App, Authorization

On this page