Module: Dry::Validation::Macros

Defined in:
lib/dry/validation/macros.rb

Overview

API for registering and accessing Rule macros

Defined Under Namespace

Modules: Registrar Classes: Container

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Proc

Return a registered macro

Parameters:

  • name (Symbol)

    The name of the macro

Returns:

  • (Proc)


75
76
77
# File 'lib/dry/validation/macros.rb', line 75

def self.[](name)
  container[name]
end

.containerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



92
93
94
# File 'lib/dry/validation/macros.rb', line 92

def self.container
  @container ||= Container.new
end

.register(name, *args, &block) ⇒ Macros

Register a global macro



86
87
88
89
# File 'lib/dry/validation/macros.rb', line 86

def self.register(name, *args, &block)
  container.register(name, *args, &block)
  self
end