Options available for schema properties
When defining properties in a schema, you can configure various options to specify validation rules, labels, and more.
The simplest way to define a property is to specify its type:
In this example, Orionjs applies appropriate validation based on the specified types.
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:
number
: Minimum and maximum numeric valuesstring
: Minimum and maximum string lengthDate
: Minimum and maximum dateallowedValues
Restricts the field to a set of allowed values.
defaultValue
Sets a default value for the field if none is provided.
You can create custom validation logic using the validate
option:
The validate function:
The clean
option allows you to transform data before validation:
The clean function:
To define an array of values, use the array syntax in the type field:
For arrays of complex types, you can reference other schemas:
You can nest schemas inside other schemas:
Options available for schema properties
When defining properties in a schema, you can configure various options to specify validation rules, labels, and more.
The simplest way to define a property is to specify its type:
In this example, Orionjs applies appropriate validation based on the specified types.
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:
number
: Minimum and maximum numeric valuesstring
: Minimum and maximum string lengthDate
: Minimum and maximum dateallowedValues
Restricts the field to a set of allowed values.
defaultValue
Sets a default value for the field if none is provided.
You can create custom validation logic using the validate
option:
The validate function:
The clean
option allows you to transform data before validation:
The clean function:
To define an array of values, use the array syntax in the type field:
For arrays of complex types, you can reference other schemas:
You can nest schemas inside other schemas: