[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] NotNaughty - Validation Framework 0.4

Florian Aßmann

2/25/2008 2:57:00 PM

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/n...

== 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

1 Answer

Avdi Grimm

2/25/2008 3:05:00 PM

0

On Mon, Feb 25, 2008 at 9:57 AM, Florian A=DFmann
<florian.assmann@email.de> wrote:

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

--=20
Avdi