N NezamDocumentation

Types and literals#

Type expressions describe values, declarations, parameters, table fields, messages, validation functions, and service APIs.

Built-in types#

The grammar recognizes these built-in families:

FamilyTypes
Textstring, text, email, phone, url
Integerinteger, int, long, uint, ulong
Numberfloat, double, decimal, number, percentage, percent
Booleanboolean, bool
Timedatetime, timestamp, date, time, duration
IDsuuid, node_id, guid
Payloadjson, blob, xml
Media/locationcoordinate, geolocation, color, image, file
Patternregex, pattern_type
Controlvoid

Nullable and array types#

bl
struct TypeExamples {
  field optional_vendor_id: VendorId?;
  field line_amounts: decimal[];
  field matrix: decimal[][];
}

Unions and intersections#

bl
type ExternalId: string | uuid;
type AuditedCustomer: Customer & AuditedRecord;

Generics#

Generic arguments can use angle brackets or square brackets.

bl
field page: Page<Customer>;
field lookup: Map[string, Customer];

Type declarations do not currently accept declaration-site generic parameters. Use generic arguments at reference sites.

bl
type CustomerResult {
  value: Customer;
}

type CustomerPage: Page<Customer>;

Function, reference, tuple, and mapped types#

bl
field predicate: (Customer) -> bool;
field callback: function(Customer, decimal): bool;
field customer_ref: ref<Customer>;
field pair: (string, decimal);
field projection: { [K in Keys]: string };

Conditional types#

bl
type Output: SourceValue extends string ? TextOutput : JsonOutput;

Operator and suffix order#

Type expressions support union |, intersection &, conditional T extends U ? A : B, suffixes such as [] and ?, literal parameters, and generic arguments.

bl
type MaybeIds: string[] | uuid[]?;
type AuditedResult: AuditedRecord extends Audited ? Result<AuditedRecord> : ErrorResult;

struct TypeSuffixExamples {
  field sized_code: string(40);
  field page: Page<Customer>;
}

Function types accept ->, =>, and function(...): Return forms.

bl
field predicate: (Customer) -> bool;
field mapper: (Customer) => Json;
field callback: function(Customer, decimal): bool;

Type literal parameters#

Some types accept literal parameter lists or ranges.

bl
type ExternalCode;
type Money: decimal(18, 2);
field amount: decimal(0..1000000);
field bounded_percent: decimal(0..100);
field code: string(40);

Literals#

bl
let double_quoted = "double quoted";
let single_quoted = 'single quoted';
let template_text = `template text`;
let decimal_value = 123;
let hex_value = 0xFF;
let binary_value = 0b1010;
let float_value = 12.34;
let scientific_value = 1.2e5;
let percent_value = 25%;
let enabled = true;
let disabled = false;
let empty_value = null;
let date_value = Date("2026-04-26");
let time_value = Time("10:30");

Arrays and objects#

bl
let empty = [];
let values = [1, 2, ...more_values];

let payload = {
  name: "Vendor",
  amount: 100,
  [dynamic_key]: true
};

Object properties can be separated with commas or semicolons.

Source: packages/business/language/types-literals.md