ConstCreate a string type with optional constraints.
Optionaloptions: { min?: number; max?: number; pattern?: string; description?: string }Create a UUID string type (RFC 4122).
Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Language mappings:
Optionaldescription: stringCreate an ISO 8601 datetime string type.
Format: 2024-01-01T12:00:00Z
Language mappings:
Optionaldescription: stringCreate a 32-bit signed integer type.
Range: -2,147,483,648 to 2,147,483,647
Language mappings:
Optionaloptions: { min?: number; max?: number; description?: string }Create a 64-bit signed integer type.
Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Note: JavaScript can only safely represent integers up to 2^53.
Language mappings:
Optionaloptions: { min?: number; max?: number; description?: string }Create a 32-bit floating point number type.
Language mappings:
Optionaloptions: { min?: number; max?: number; description?: string }Create a 64-bit floating point number type.
Language mappings:
Optionaloptions: { min?: number; max?: number; description?: string }Create a boolean type.
Language mappings:
Optionaldescription: stringCreate a bytes type for binary data. Maps to:
Optionaldescription: stringCreate an array type with element type and optional size constraints.
Optionaloptions: { min?: number; max?: number; description?: string }Create an object type with named properties.
Required fields are automatically determined based on the optional flag.
Optionaldescription: stringCreate an enum type with fixed string values.
Optionaldescription: stringCreate a union type representing one of multiple possible types.
Optionaldescription: stringCreate a generic number type (defaults to double for floating point). This is a convenience wrapper for double().
Optionaloptions: { min?: number; max?: number; description?: string }Create a void type for functions that don't return a value.
import { bsb, optional } from '@bsb/base';
const UserSchema = bsb.object({
id: bsb.uuid('User unique identifier'),
name: bsb.string({ min: 1, max: 100, description: 'User full name' }),
email: bsb.string({ description: 'User email address' }),
age: optional(bsb.int32({ min: 0, max: 150, description: 'User age' })),
});
BSB type builder providing a fluent API for creating cross-language type definitions.