Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (24 sloc) 788 Bytes


We write a lot of validations in our ActiveRecord models that already exist inside of our database. This gem automatically creates those validations.


We need more tools that use tools we already have

class Thing < ActiveRecord::Base
  include DatabaseValidation

What's automatically created

For now:

  • validates_uniquness_of (with scope)
  • validates_presence_of
  • validates_inclusion_of (for booleans)
  • validates_length_of :maximum, :allow_nil
  • validates_numericality_of :greater_than, :less_than, :allow_nil

In the future:

  • all associations

Tested Adapters (probably others)

  • mysql
  • mysql2


# in your Gemfile
gem 'database_validation'


John Crepezzi

Jump to Line
Something went wrong with that request. Please try again.