Skip to content

Support Rails 6.1-style errors #3

@joshpencheon

Description

@joshpencheon

Rails 6.1 has changed how errors are structured internally, which will affect how activemodel-caution should function.

See the new API docs.

# On the rails/rails repo:
$ git diff v6.0.3.5..v6.1.2.1 --stat -- {activemodel/lib/active_model,activerecord/lib/active_record}/{error,validat}*
 activemodel/lib/active_model/error.rb                      | 207 +++++++++++++++
 activemodel/lib/active_model/errors.rb                     | 524 +++++++++++++++++++++++---------------
 activemodel/lib/active_model/validations.rb                |  12 +-
 activemodel/lib/active_model/validations/absence.rb        |   2 +-
 activemodel/lib/active_model/validations/acceptance.rb     |   2 +-
 activemodel/lib/active_model/validations/callbacks.rb      |  30 +--
 activemodel/lib/active_model/validations/clusivity.rb      |   6 +-
 activemodel/lib/active_model/validations/confirmation.rb   |   4 +-
 activemodel/lib/active_model/validations/exclusion.rb      |   2 +-
 activemodel/lib/active_model/validations/format.rb         |   4 +-
 activemodel/lib/active_model/validations/inclusion.rb      |   2 +-
 activemodel/lib/active_model/validations/length.rb         |   4 +-
 activemodel/lib/active_model/validations/numericality.rb   |  95 ++++---
 activemodel/lib/active_model/validations/presence.rb       |   2 +-
 activemodel/lib/active_model/validations/validates.rb      |  10 +-
 activemodel/lib/active_model/validator.rb                  |   8 +-
 activerecord/lib/active_record/errors.rb                   |  59 ++++-
 activerecord/lib/active_record/validations.rb              |   1 +
 activerecord/lib/active_record/validations/numericality.rb |  35 +++
 activerecord/lib/active_record/validations/uniqueness.rb   |  28 +-
 20 files changed, 734 insertions(+), 303 deletions(-)

We'll likely need to swap activemodel-caution over to the new structure, as well as mirror the deprecations.

Frustratingly, we've still got a number of use cases for the "active" warnings... regardless, I wonder if it might not be possible to change how this gem functions - to give objects a proxy "warning object" that uses ActiveModel::Error, meaning we'd not be duplicating the entire library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions