On Aug 28, 2011, at 11:23 AM, Saurabh Sawant wrote: > They seem fine. Although, having ready to use validators would save > some time for those learning the framework. I personally expected > those validators to be already there while I was learning.
Trouble is, there's an endless list of pattern expressions that can be useful. IS_MATCH is pretty powerful, and should be in your bag of tricks (in fact, IS_ALPHANUMERIC just calls IS_MATCH). At the very least, consider that you might want a language-dependent IS_LETTERS, or at least one that accepts the common alphabetic variants. However, if you do that, do it this way: IS_MATCH('[0-9]+', strict=True) IS_MATCH('[a-zA-Z]+', strict=True) strict=True forces a $ at the end of the regex. Or you can just include the $. (IS_MATCH is already anchored at the beginning of the string.) > > On Aug 28, 11:05 pm, Massimo Di Pierro <massimo.dipie...@gmail.com> > wrote: >> what's wrong with? >> >> IS_MATCH('[0-9]+') >> IS_MATCH('[a-zA-Z]+') >> >> On Aug 28, 12:59 pm, Saurabh Sawant <ris...@gmail.com> wrote: >> >> >> >> >> >> >> >>> But IS_ALPHANUMERIC by virtue of its name suggests both letters and >>> numbers. Having separate validators for each of the cases would make >>> the code more readable. >> >>> db.auth_user.first_name.requires=IS_LETTERS() >>> db.auth_user.age.requires=IS_DIGITS() >