module Hv::ErrorsProcessor

Public Class Methods

call(result, i18n_errors_hash) click to toggle source
# 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_errors() click to toggle source
# 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