The project is in a healthy, maintained state
Scans ActiveRecord models and adds automatic validations based on null, max length etc.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 7.0.3
 Project Readme

ActiveRecordAutoValidations

Short description and motivation.

Usage

How to use my plugin.

Installation

Add this line to your application's Gemfile:

gem "active_record_auto_validations"

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_record_auto_validations

Add this initializer:

Rails.autoloaders.main.on_load do |_klass_name, klass, _defined_by_file|
  ActiveRecordAutoValidations::OnLoad.execute!(klass: klass)
end

To run auto-validations on all models you can add something like this to ApplicationRecord:

class ApplicationRecord < ActiveRecord::Base
  primary_abstract_class

  def self.inherited(child)
    super
    child.include ActiveRecordAutoValidations::ModelConcern
  end
end

To run auto-validations on a single model you can do this:

class Project < ApplicationRecord
  include ActiveRecordAutoValidations::ModelConcern
end

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.