I've got a working implementation for a plugin that allows an alternative syntax for the validation_helpers plugin's methods (http:// pastie.org/662251.txt):
def validate validates do name do presence max_length 10 end date do format %r{\d\d/\d\d/\d\d\d\d} end number do presence integer end end end This syntax is a lot more verbose than the standard syntax, but I have a fairly specific use case in mind. The project I'm working on currently has a table with about 80-90 columns all with validation requirements. Using the standard syntax, it's difficult to see what validations apply to each column, since the validations are sorted by type of validation (e.g. presence, max_length), not by column. This type of syntax allows me to basically print out the validation code, sit with project manager, and make sure all desired validations are being enforced. I think it is more natural to think of all validations for a given column, versus all columns with a certain validation type. Of course, if you only have a few columns, this syntax is just more verbose. This syntax really only has an advantage when you have many columns and it is difficult to look at your validate method and see what validations are being applied to what columns. Anyway, I'd like to get some feedback as to whether people think this should be added to the plugins that ship with Sequel. Also, I'd like to thank Rich Kilmer for the general idea of this type of syntax. I got the idea from his LoneStar RubyConf presentation on "Encoding Domains". Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to sequel-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---