Class: Validations::Message
- Inherits:
-
Object
- Object
- Validations::Message
- Defined in:
- lib/validations/message.rb
Constant Summary collapse
- CLASSIFY_SEPARATOR =
'_'.freeze
- TITLEIZE_SEPARATOR =
' '.freeze
Instance Method Summary collapse
-
#build(errors, parent = nil) ⇒ Object
Output: array of string that can be used to feed into Errors::InvalidParamsError.
Instance Method Details
#build(errors, parent = nil) ⇒ Object
Output: array of string that can be used to feed into Errors::InvalidParamsError
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/validations/message.rb', line 12 def build(errors, parent = nil) case errors when Hash errors.flat_map do |key, value| child = [parent, key].compact.join(' ') build(value, child) end when Array errors.flat_map do |error| "#{titleize(parent.to_s)} #{build(error)}" end else errors end end |