Skip to content

Fields

Field types and validation rules.

Fields define the shape of your resource data. Each field has a name, a type, and optional properties that control validation, sorting, search, and automatic value generation.

Field types

Snaapi supports 10 field types.

Type Description When to use
string Short text value (up to database column limit) Titles, names, slugs, email addresses
number Numeric value (integer or floating-point) Prices, counts, ratings, quantities
boolean true or false Flags like "in stock", "published", "verified"
json Arbitrary JSON object or array Metadata, settings, or flexible structured data
datetime ISO 8601 date-time string Event dates, deadlines, scheduled times
timestamp Unix timestamp (numeric) Unix-style timestamps for system interop
uuid UUID v4 string External IDs or references not managed by Snaapi
text Long-form text (unlimited length) Blog post bodies, descriptions, comments
enum One of a predefined set of string values Statuses, categories, roles, or any fixed choices
relation Foreign key reference to another resource Linking resources together (see Relations)

Enum fields

Enum fields require a list of allowed values, supplied via the Enum values input on the field configuration.

Relation fields

Relation fields require a target resource, a target field, and a relation kind (one-to-one, one-to-many, many-to-one, or many-to-many). See Relations for details.

Field properties

Properties control how a field behaves within a resource.

Property Type Default Description
required boolean false Whether the field must be provided on create
sortable boolean false Whether the field can be used in sort operations
searchable boolean false Whether the field is included in full-text search
unique boolean false Whether values must be unique across all records
defaultValue any (none) Value used when the field is omitted on create

Additional optional metadata:

  • description. Human-readable description (up to 500 characters).
  • displayName. Label for UI rendering (up to 200 characters).
  • contentType. Semantic hint for UI and data generation (see Content types).

The field names id, created_at, and updated_at are reserved as system fields and cannot be used for custom fields. When enableSoftDelete is true on a resource, deleted_at is also reserved.

Validation rules

You can attach validation rules to string and number fields via the validations array. Each rule is checked at write time.

String validations

Available on string fields.

Rule Parameters Description
minLength value (number) Minimum character count
maxLength value (number) Maximum character count
regex pattern, optional flags Must match the regular expression
email (none) Must be a valid email address
url (none) Must be a valid URL

Text validations

Available on text fields.

Rule Parameters Description
minLength value (number) Minimum character count
maxLength value (number) Maximum character count

Number validations

Available on number fields.

Rule Parameters Description
min value (number) Minimum allowed value (inclusive)
max value (number) Maximum allowed value (inclusive)

Display metadata

A field can carry a displayName and a description. These do not affect the API contract, but they flow through to the generated documentation page and the API builder, so non-technical readers see human-friendly labels rather than raw column names.

Next

Permissions explains how to expose specific fields to specific roles.