Skip to content


For all currently supported schema types, AJV is used as the default validator. See the validators API documentation for more information.

AJV validators

The src/validators.ts file sets up two Ajv instances for data and querys (for which string types will be coerced automatically). It also sets up a collection of additional formats using ajv-formats. The validators in this file can be customized according to the Ajv documentation and its plugins. You can find the available Ajv options in the Ajs class API docs.

import { Ajv, addFormats } from '@feathersjs/schema'
import type { FormatsPluginOptions } from '@feathersjs/schema'

const formats: FormatsPluginOptions = [

export const dataValidator = addFormats(new Ajv({}), formats)

export const queryValidator = addFormats(
  new Ajv({
    coerceTypes: true

MongoDB ObjectIds

When choosing MongoDB, the validators file will also register the objectid keyword to convert strings to MongoDB Object ids.

Released under the MIT License.