NotNaughty - Validation Framework 0.4

Hi folks,

I just released my first gem. It’s a validation framework that targets
an easy
way of creating validations and reuse them in any ruby project that
needs to
validate any kind of values.

It’s syntax is close to the ActiveRecord and Assistance validations with
some
enhancements.

http://rubyforge.org/projects/not-naughty

== Features

  • Easy to extend

  • Easy to adapt (provides an adapter/plugin for sequel models)

    class MyClass
    extend NotNaughty
    validated_before :clone

    snip

    end

    class MyModel < Sequel::Model
    is :not_naughty
    end

  • Supports inheritance

  • Validator can handle object states

  • Supports chained conditions for validations

  • Comes with default validations for presence, length, …

  • Magic builder methods that take global attributes and conditions

    validates(:attribute1, :attribute2) {
    confirmation and presence :if => [:true?, :really_true?]
    }
    validates {
    confirmation_of :attribute1, :attribute2
    presence_of :attribute1, :attribute2, :if => [:true?,
    :really_true?]
    }
    validates(:if => [:true?, :really_true?]) {
    presence_of :attribute1, :attribute2
    }

    They just drop in if you inherit from NotNaughty::Validation.

  • Error messages are eval’ed (not glued) which gives you more control

  • Lots of examples in the specs and documentation

== Installation

sudo gem install not_naughty

== ToDo

Awaiting feature requests…

Cheers
Florian

On Mon, Feb 25, 2008 at 9:57 AM, Florian Aßmann
[email protected] wrote:

Nice! A non ActiveRecord-specific validations module is something
I’ve wanted in the past.