Folks,
this morning I’ve crafted first validation primitive for StrokeDB— validates_presence_of
Here you are few examples of it:
User = StrokeDB::Meta.new do
validates_presence_of :login
end
# ==> User
User.create! rescue $!.message
# ==> "User's login should be present on save"
User = StrokeDB::Meta.new do
validates_presence_of :login, :on => :create # or :save or :update
end
User = StrokeDB::Meta.new do
validates_presence_of :login, :message => '#{meta} should always have #{slotname} to be able to log in'
end
# ==> User
User.create! rescue $!.message
# ==> "User should always have login to be able to log in"
More validations to appear soon.
Enjoy!





Have you looked at the Validatable gem on rubyforge? It has validates_presence_of, along with half a dozen others. The DataMapper (http://www.datamapper.org) project is currently using it as a base for their validations.
Dan, yes — I looked at it (I was advised to look at it on StrokeDB’s mailing list), though I am not yet sure it could be easily integrated into StrokeDB. Though I haven’t investigated it thoroughly.
Anyway, thanks!