Cedalio
Search
K

Data validations

Cedalio enhances data validation through the inclusion of custom scalars and schema directives.

Data validations

By default, Cedalio ensures that the data sent to each field matches the expected type, validating the correctness of the values for all scalars.
In addition, you have the ability to validate the actual data values using custom directives specifically designed for use within your Cedalio schema.

@unique

The @unique directive tells Cedalio that this value must be unique (and case-sensitive) within the collection.
Schema
type User @model {
email: String! @unique
}

Scope

You can set additional fields to the @unique directive that will be used when checking for uniqueness.
Schema
Ussage
type User @model {
name: String
provider: String! @unique(fields: ["providerAccountId"])
providerAccountId: String!
}
query {
user(
by: {
providerAndProviderAccountId: {
provider: "github"
providerAccountId: "notrab"
}
}
) {
name
}
}

@length

The @length directive enables specifying a minimum or a maximum (or both) value for a field.
The following example rejects mutations for Post objects with a title field value less than 10 characters or more than 255 characters, or more than five tags values:
Schema
type Post @model {
title: String @length(min: 10, max: 255)
tags: [String] @length(max: 5)
}