class ViewModel::DeserializationError::Validation
def self.from_active_model(errors, node)
Return Validation errors for each error in the the provided
def self.from_active_model(errors, node) causes = errors.messages.each_key.flat_map do |attr| errors.messages[attr].zip(errors.details[attr]).map do |message, details| self.new(attr.to_s, message, details, node) end end Collection.for_errors(causes) end
def detail
def detail "Validation failed: '#{attribute}' #{reason}" end
def initialize(attribute, reason, details, node)
def initialize(attribute, reason, details, node) @attribute = attribute @reason = reason @details = details super([node]) end
def meta
def meta super.merge(attribute: attribute, message: reason, details: details) end