>> I'm not fond of Rails' style of validation where one rule is followed
>> by many fields.
>> Trying to determine the rules of any one field is rather tedious with
>> this setup.
>> I'd rather have one field, followed by many rules.
>> Anyone know if someone has already written something to do it that
>> way? If not, I think I'll take a crack at it. It would likely look
>> something like this:
>> validates_field
>> 'field_name', :isRequired, :isAlphaNumeric, :hasMaxLength => 10
>> Which would ultimately just translate and inject definitions into
>> Rails' existing internal structure, but at least I can read it field
>> by field (and with a number of explicit easier-to-read keywords I'll
>> borrow from my past work).
> This took about ten minutes to write and test:
Cool. I started someting similar, but the send idea was a good one
that should help finish the exepriment. Thanks for exploring it for me.
> Making up new keywords from your past work is fine if you are the only
> one who will have to read this code. But you will slow
> understanding for all
> the developers who read AWDWR and are familiar with the standard
> names.
But once they use my way, I'll speed them up because they won't spend
five minutes mentally compiling what all the rules are for a given
field by hunting through all those inverted rules, and they won't
spend time deciphering, remembering, and making typos in their regexs
for the common stuff. Regex is handy, but it's a speed bump every
time you have to read it or write it.
Rails has lot sof neat stuff. Rails isn't perfect. So, I'm working my
way through it and trying to decide where I need to spend time
filling in holes and providing alternatives that I think are better
from my past work. Some is just different, but a few I believe I had
better. I understand the advantages sticking to what's provided, but
I think this is an area worth improving. The current method is quite
cumbersome to read, write, and maintain IMO.
> Also, your use of camelCase is non-standard and will make other Ruby
> programmers think you are just an unreformed Java hacker.
I've never liked underscore words. A line of rails code feels like
someone took a shot gun to it and filled it full of holes. Can't tell
where phrases stop and start because it's so full of empty spaces.
Not to mention how awkward it is to type.
That's your editor's fault. Get a better editor, or customize the one
you are using.
Since ruby does not use the semicolon, I customized mine to map
semicolon to underscore.
Now it's easier for me to type an underscore than a capital letter.
Conforming is fine (I understand the advantages), but I hate that I have to conform to
something so ugly.
After a while, you will get used to it, and it won't seem so ugly.
And if you go against standard
practices, the inconsistency between your code and the library code
will be even uglier.