class Dry::Schema

Main interface

@api public

Common constants used across the library

@api public

Constants

DEFAULT_MESSAGES_PATH

Path to the default set of localized messages bundled within the gem

DEFAULT_MESSAGES_ROOT

Default namespace used for localized messages in YAML files

DOT
InvalidSchemaError

An error raised when DSL is used in an incorrect way

LIST_SEPARATOR
MissingMessageError

An error raised when a localized message cannot be found

QUESTION_MARK
STEPS_IN_ORDER

core processor steps in the default execution order

VERSION

Public Class Methods

JSON(**options, &block) click to toggle source

Define a schema suitable for JSON data

This schema type uses `Types::JSON` for coercion by default

@example

Dry::Schema.JSON do
  required(:name).filled(:string)
  required(:age).value(:integer, gt?: 0)
end

@return [Params]

@see Schema#define

@api public

# File lib/dry/schema.rb, line 84
def self.JSON(**options, &block)
  define(**options, processor_type: JSON, &block)
end
Params(**options, &block) click to toggle source

Define a schema suitable for HTTP params

This schema type uses `Types::Params` for coercion by default

@example

Dry::Schema.Params do
  required(:name).filled(:string)
  required(:age).value(:integer, gt?: 0)
end

@return [Params]

@see Schema#define

@api public

# File lib/dry/schema.rb, line 64
def self.Params(**options, &block)
  define(**options, processor_type: Params, &block)
end
config() click to toggle source

Configuration

@example

Dry::Schema.config.messages.backend = :i18n

@return [Config]

@api public

# File lib/dry/schema.rb, line 26
def self.config
  @config ||= Config.new
end
define(**options, &block) click to toggle source

Define a schema

@example

Dry::Schema.define do
  required(:name).filled(:string)
  required(:age).value(:integer, gt?: 0)
end

@param [Hash] options

@return [Processor]

@see DSL.new

@api public

# File lib/dry/schema.rb, line 45
def self.define(**options, &block)
  DSL.new(**options, &block).call
end