Skip to main content
When defining properties in a schema, you can configure various options to specify validation rules, labels, and more.

Basic Property Definition

The simplest way to define a property is to specify its type:
In this example, Orionjs applies appropriate validation based on the specified types.

Available Options

Each property in the schema can have the following options:

label

A human-readable label for the field, useful for UI generation and error messages.

description

Provides a description for the field, which will be included in GraphQL schema generation.

optional

By default, all fields are required. Set optional: true to make a field optional.

private

Fields marked as private will not be exposed in the GraphQL API.

min / max

These options provide validation constraints based on the field type:
  • For number: Minimum and maximum numeric values
  • For string: Minimum and maximum string length
  • For Date: Minimum and maximum date

allowedValues

Restricts the field to a set of allowed values.

defaultValue

Sets a default value for the field if none is provided.

Custom Validation

You can create custom validation logic using the validate option:
The validate function:
  • Receives the field value as its first parameter
  • Should return an error message string if validation fails
  • Should return nothing (undefined) if validation passes
  • Can be an async function

Custom Data Transformation

The clean option allows you to transform data before validation:
The clean function:
  • Receives the field value as its first parameter
  • Should return the transformed value
  • Can be an async function

Working with Arrays

To define an array of values, use the array syntax in the type field:
For arrays of complex types, you can reference other schemas:

Nested Schemas

You can nest schemas inside other schemas: