-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi all,
sorry for abusing the webware-discuss-list again for questions related to FormKit. :-)
I downloaded the latest release (0.6.1) from the Webpage recently and used it for an in-house-application (web-based database-frontend for a tiny laboratory-management-system (sort of ;-))).
While fumbling around with validators I found, that they have two common disadvantages (for me):
1. The error-messages are hard-coded (i.e. english text). 2. Most of them actually test for two things at once, existance AND correct format of field-input.
I don't know about a beta-version or the most recent stuff from cvs (if any), so maybe my thoughts and my work is outdated allready, but anyway:
To solve this problem, I rewrote Validators, so that every class has a function "_message(self)", which holds the message-string (and which could be easily replaced by subclassing). An alternative would be to parametrize the Validators and provide an error-message on the fly.
2. In my eyes, validation of required field should be done separately from validation of correct format/input, because (at least for my app) there are often fields, which need to be checked for correct input (i.e. all fields) but are not required.
Therefore I always add "validators = [self.valNotEmpty, self.valIsWhateverFormat]" to check for a required field AND correct formatting and only "validators = [self.valIsWhateverFormat]" to check correct format only. Slightly more verbose but more clear and without side-effects.
I rewrote most of the validators to conform to this scheme, i.e. most of the time simply adding
if not value: ~ return None # We only want to check syntax not require field
at the beginning of "_validate(self, value)".
If someone is interested in this stuff I could upload it.
Maybe I'm wrong here (or have overlooked something). So feedback would be appreciated.
- -- Bye, Marc Saric -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFA7QSbvKxJUF29wRIRAqBGAJ9hCPiPhWluzADFWvvgJQ/FA5yaUQCfbynk r2JUDNBHjJ/EV2RbAY/sF/c= =eakS -----END PGP SIGNATURE-----
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss
