Module: Dry::Validation

Extended by:
Core::Extensions
Includes:
Core::Constants
Defined in:
lib/dry/validation.rb,
lib/dry/validation/result.rb,
lib/dry/validation/schema.rb,
lib/dry/validation/message.rb,
lib/dry/validation/version.rb,
lib/dry/validation/executor.rb,
lib/dry/validation/messages.rb,
lib/dry/validation/schema/dsl.rb,
lib/dry/validation/schema/key.rb,
lib/dry/validation/type_specs.rb,
lib/dry/validation/compat/form.rb,
lib/dry/validation/message_set.rb,
lib/dry/validation/schema/form.rb,
lib/dry/validation/schema/json.rb,
lib/dry/validation/schema/rule.rb,
lib/dry/validation/deprecations.rb,
lib/dry/validation/schema/check.rb,
lib/dry/validation/schema/value.rb,
lib/dry/validation/messages/i18n.rb,
lib/dry/validation/messages/yaml.rb,
lib/dry/validation/schema/params.rb,
lib/dry/validation/schema_compiler.rb,
lib/dry/validation/message_compiler.rb,
lib/dry/validation/extensions/monads.rb,
lib/dry/validation/extensions/struct.rb,
lib/dry/validation/messages/abstract.rb,
lib/dry/validation/schema/deprecated.rb,
lib/dry/validation/predicate_registry.rb,
lib/dry/validation/messages/namespaced.rb,
lib/dry/validation/schema/class_interface.rb,
lib/dry/validation/input_processor_compiler.rb,
lib/dry/validation/input_processor_compiler/json.rb,
lib/dry/validation/message_compiler/visitor_opts.rb,
lib/dry/validation/input_processor_compiler/params.rb,
lib/dry/validation/input_processor_compiler/sanitizer.rb

Defined Under Namespace

Modules: Deprecations, Messages, TypeSpecs Classes: ApplyChecks, ApplyInputRule, ApplyRules, BuildErrors, Executor, Guard, Hint, InputProcessorCompiler, Message, MessageCompiler, MessageSet, PredicateRegistry, ProcessInput, Result, Schema, SchemaCompiler

Constant Summary collapse

MissingMessageError =
Class.new(StandardError)
InvalidSchemaError =
Class.new(StandardError)
VERSION =
'0.12.1'.freeze

Class Method Summary collapse

Class Method Details

.JSON(base = Schema::JSON, **options, &block) ⇒ Object



32
33
34
35
# File 'lib/dry/validation.rb', line 32

def self.JSON(base = Schema::JSON, **options, &block)
  klass = base ? Schema::JSON.configure(Class.new(base)) : Schema::JSON
  Validation.Schema(klass, options, &block)
end

.messages_pathsObject



12
13
14
# File 'lib/dry/validation.rb', line 12

def self.messages_paths
  Messages::Abstract.config.paths
end

.Params(base = nil, **options, &block) ⇒ Object Also known as: Form



27
28
29
30
# File 'lib/dry/validation.rb', line 27

def self.Params(base = nil, **options, &block)
  klass = base ? Schema::Params.configure(Class.new(base)) : Schema::Params
  Validation.Schema(klass, options, &block)
end

.Schema(base = Schema, **options, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/dry/validation.rb', line 16

def self.Schema(base = Schema, **options, &block)
  schema_class = Class.new(base.is_a?(Schema) ? base.class : base)
  klass = schema_class.define(options.merge(schema_class: schema_class), &block)

  if options[:build] == false
    klass
  else
    klass.new
  end
end