active_data
active_data copied to clipboard
Incompatible with ActiveModel 6.1
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.