Class: ErrorNormalizer
- Inherits:
-
Object
- Object
- ErrorNormalizer
- Extended by:
- Dry::Configurable
- Defined in:
- lib/error_normalizer.rb,
lib/error_normalizer/error.rb,
lib/error_normalizer/version.rb,
lib/error_normalizer/normalizer.rb,
lib/error_normalizer/message_parser.rb,
lib/error_normalizer/message_parser/english.rb,
lib/error_normalizer/schema_path_translator.rb
Overview
This class provides high-level API to normalize errors to the single format:
{
key: 'has_already_been_taken',
type: 'params',
message: 'has already been taken',
payload: {
path: 'user.email'
}
}
Defined Under Namespace
Classes: Error, MessageParser, Normalizer, SchemaPathTranslator
Constant Summary collapse
- VERSION =
'0.3.0'
Class Method Summary collapse
-
.normalize(input, **opts) ⇒ Array<Hash>
Normalize errors to flat array of structured errors.
Class Method Details
.normalize(input, **opts) ⇒ Array<Hash>
Normalize errors to flat array of structured errors.
36 37 38 39 |
# File 'lib/error_normalizer.rb', line 36 def self.normalize(input, **opts) defaults = config.to_hash Normalizer.new(input, defaults.merge(opts)).normalize.to_a end |