Module: Remap::Types

Defined in:
lib/remap/types.rb

Overview

Defines callable types used throughout the application

Constant Summary collapse

Backtrace =
Array(Interface(:to_s) | String)
Enumerable =
Any.constrained(type: Enumerable)
Nothing =
Constant(Remap::Nothing)
Mapper =
Interface(:call!)
Rule =
Interface(:call) | Instance(Proc)
Key =
Interface(:hash)
Notice =
Instance(Remap::Notice)
ID =
String | Symbol
State =

Validates a state according to State::Schema

Hash.constructor do |input, type, &error|
  input = type.call(input, &error)
  result = Remap::State::Schema.call(input)
  error ||= -> { raise _1 }

  next input if result.success?

  error[result.errors.to_h.formatted]
end