Skip to content

Incompatible with ActiveModel 6.1 #75

@rewritten

Description

@rewritten

The ActiveModel::Errors class has changed, keeping most of the high level API compatible, but some of the underlying implementation are not working anymore.

The class ActiveData::Model::Validations::NestedValidator is not compatible with the new implementation, it should be something on the lines of:

def self.validate_nested(record, name, value)
  if value.is_a?(Enumerable)
    value.each.with_index do |object, i|
      if yield(object)
        object.errors.each do |error|
          record.errors.import(error, attribute: "#{name}.#{i}.#{error.attribute}")
        end
      end
    end
  elsif value && yield(value)
    value.errors.each do |error|
      record.errors.import(error, attribute: "#{name}.#{error.attribute}")
    end
  end
end

but of course this only works with the new errors interface… so maybe a version check? I haven't been able to find a version-independent way to achieve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions