So this isn't really supported by other ORM's and I can't find a match
in the Sequel rdoc for validations, so it's probably not supported.
But maybe there's a way to accomplish this.
One thing I've always wanted is class-level validation hooks that can
specify an arbitrary method name to run the validation :on. For
example some pseudo-AR-code:
class UserCreation < AR::Base
validates_presence_of :page, :on => [:search, :list]
validates_presence_of :per_page, :on => [:search, :list]
validates_presence_of :search_string, :on => :search
end
Then:
UserCreation.list(params[:list])
UserCreation.search(params[:search])
Now, I know in Sequel you can just do this via instance methods/etc.
The reason class methods have alot of value for my app is we do alot
of reflection on our XML/JSON services side to basically self-document
our API (eg, we generate a RelaxNG structure that shows params,
request method, response structure, etc). So this way we can say
UserCreation.validations_for(:search).each.etc.etc
(Currently we have a custom plugin for AR that we run locally to
accomplish this.)
Thoughts? If similar functionality already exists in Sequel, great,
otherwise Jeremy are you open to me extending the
validation_class_methods plugin to accomplish this?
class MyClass < Sequel::Model
validates :on => [:search, :list] do
numericality_of :page
numericality_of :per_page
end
validates :on => :search do
length_of :search_string
end
end
I can also monkey-patch locally, I just like to feed stuff back when I
can.
-Nate
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---