Proposal: ActiveModel::Normalization

ActiveRecord::Normalization is such a nice new feature of Rails 7.1. However, it is only available for ActiveRecord, even though ActiveModel-based classes could also benefit from its features.

ActiveModel-based classes are for example used as Form Objects. Here, the normalization of user input would be very benefitial.

This is why I am proposing to move over most of the features of ActiveRecord::Normalization to ActiveModel::Normalization.

3 Likes

I opened a discussion at rails/rails for this idea. See Bring ActiveRecord::Normalization to ActiveModel · rails/rails · Discussion #53793 · GitHub

Besides this, I created a small blog post about ActiveRecord::Normalization some time ago, where I also addressed that disadvantage. See How to enable reusability for `ActiveRecord::Base::normalizes` - Tobias L. Maier

See