Gem Version Build Status Dependency Status Code Climate Coverage License

The Thor-based scaffolder of custom ActiveModel validators with unit test and its support files.

The module is the part of [hexx] scaffolders collection.


Add this line to your application's Gemfile:

    gem "hexx-validators"

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install hexx-validators


require "hexx-validators"

Hexx::Validators::Generator.start %w(
    -o allow_nil time_zone
    -e not_in_the_past

Arguments and Options

The generator takes one argument (the name of the validator, such as in_the_past) and two options:

  • -o - the names of validator options (such as allow_nil etc.).
  • -e - the names of error messages for I18n translations.

Depending on options the unit test spec will be pre-populated with combinations of options.

Provided Results

The generator creates:

  • the validator (app/validators/in_the_past.rb) by convention I follow, it will be namespaced correspondingly: MyGem::Validators::InThePast.
  • the unit test specification spec/tests/validators/in_the_past_spec.rb.


Tested under MRI rubies >= 2.1. Rubies under 2.1 aren't supported.

Uses [RSpec] 3.0+ for testing and [hexx-suit] for dev/test tools collection.


  • Fork the project.
  • Read the STYLEGUIDE.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with Rakefile or version (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.