๐ง ActiveBuddy โ AI-assisted Model Validator for Rails
ActiveBuddy is a professional-grade Ruby gem that intelligently analyzes your ActiveRecord models and suggests validations and associations based on column names, data types, constraints, and naming conventions.
Perfect for jump-starting new Rails projects with smart, conventional best-practice validations.
๐ฏ Features
- โ
Smart inference of:
presenceuniquenesslengthnumericalityformatvalidations
- ๐งฉ Association recommendations:
belongs_to,has_many, etc.
- ๐ Custom rule engine based on Rails conventions and common model types (User, Payment, Account, etc.)
- ๐ฎ Expandable AI-based ruleset planned for future updates
๐ Installation
Add this line to your application's Gemfile:
gem 'active_buddy'
And then execute:
bundle install
Or install it yourself as a standalone gem:
gem install active_buddy
โก๏ธ Usage
In your Rails app or console:
require 'active_Buddy'
analyzer = ActiveBuddy::Analyzer.new(User)
puts analyzer.suggest_validations
puts analyzer.suggest_associations
puts analyzer.quick_audit
Output:
validates :email, presence: true
validates :email, uniqueness: true
validates :email, format: { with: /\A[^@\s]+@[^@\s]+\.[^@\s]+\z/ }
validates :name, presence: true
belongs_to :account
โ Supported Patterns
ActiveBuddy automatically picks up and suggests validations based on:
| Field Pattern | Suggested Validations |
|---|---|
email |
format, presence, uniqueness |
phone, mobile |
phone format |
name, title |
presence, length |
password |
length (>= 6) |
age, count, qty |
numericality (integer) |
price, amount |
numericality (>= 0) |
bio, description |
length (max 1000) |
status, role, type |
presence |
Also detects and formats associations from ActiveRecord relationships.
๐ Auditing model: User Fields detected: id, email, password, account_id, created_at, updated_at
โ Suggested Validations: validates :email, presence: true validates :email, uniqueness: true
๐ Suggested Associations: belongs_to :account
๐ก Tips:
- Consider adding presence validations for key fields.
- Add associations if your model connects to others (like belongs_to, has_many).
๐งช Run Specs
bundle exec rspec