Module: Hv::ErrorsProcessor

Defined in:
lib/hv/errors_processor.rb

Class Method Summary collapse

Class Method Details

.call(result, i18n_errors_hash) ⇒ Object



12
13
14
15
16
17
# File 'lib/hv/errors_processor.rb', line 12

def self.call(result, i18n_errors_hash)
  result.map do |path, validator, spec, given|
    path_text = path.empty? ? "" : " in #{path}"
    i18n_errors_hash[validator] % {path: path_text, validator: validator, spec: spec, given: given.inspect}
  end
end

.i18n_errorsObject



4
5
6
7
8
9
10
# File 'lib/hv/errors_processor.rb', line 4

def self.i18n_errors
  keys = {
    type?: "Expected %{given} to be a %{spec}"
  }
  keys.default = "Expected %{given}%{path} to be %{validator}:%{spec}"
  keys
end