GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lollar/validate_me

BranchesTags
Open more actions menu

Latest commit

 

History

12 Commits
12 Commits

Folders and files

NameName
Last commit message
Last commit date
bin
bin
 
 
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.ruby-version
.ruby-version
 
 
.travis.yml
.travis.yml
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
validate_me.gemspec
validate_me.gemspec
 
 

Repository files navigation

ValidateMe

ValidateMe offers common sense validations for your ActiveRecord models. Since it relies on different ActiveRecord abstractions it is database agnostic.

Installation

Add this line to your application's Gemfile:

gem 'validate_me'

And then execute:

$ bundle

Or install it yourself as:

$ gem install validate_me

Usage

Usage is simple, just add include ::ValidateMe to whichever ActiveRecord models you would like to have the built-in validations that will match your database constraints.

class User < ApplicationRecord
  include ::ValidateMe
end

What is validated?

ValidateMe will validate null constraints, uniqueness (including scope), and limits. See the below examples for more details

Example migration:

  create_table :users do |t|
    t.string :first_name, limit: 10, null: false
    t.string :last_name, null: false
    t.string :email, null: false, index: { unique: true }
    t.integer :phone_number, limit: 1
  end

The following validations will be added to your model:

validates :first_name, presence: true
validates :last_name,  presence: true
validates :email,      presence: true

validates :first_name, length: { maximum: 10 }
validates :phone_number, numericality: { greater_than: -127, less_than: 127 }, allow_nil: true

validates :email, uniqueness: true

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lollar/validate_me. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

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

Code of Conduct

Everyone interacting in the ValidateMe project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

No description, website, or topics provided.

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.