Reference: New Module Consideration?
Well, I've decided to go through with my idea, so now I'm wondering what types of tests would the community find most useful. The current list of tests being considered:
My code doesn't have bugs, it just develops random features.
Flame ~ Lead Programmer: GMS | GMS
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Data Validation Tests
by Aristotle (Chancellor) on Jan 26, 2003 at 00:14 UTC | |
Makeshifts last the longest. | [reply] |
|
Re: Data Validation Tests
by dempa (Friar) on Jan 25, 2003 at 23:29 UTC | |
Reading "IP" up there made me remember an, in my opinion, excellent post by ybiC: -- | [reply] |
|
Re: Data Validation Tests
by IlyaM (Parson) on Jan 26, 2003 at 09:23 UTC | |
BTW have you looked on Data::Verify? It seems to be a similar project. Have you considering cooperation?
-- | [reply] |
by Flame (Deacon) on Jan 26, 2003 at 15:26 UTC | |
An open API is already in the design. Just load the module and refer to it as a 'custom' test. I already have a test module (count and compare) that uses that mechanism because it needed to be able to curry the function. As for Data::Verify, I have looked at it, but I'm not sure if it's really practical to try to combine them directally. It's still on my "To Be Considered" list.
My code doesn't have bugs, it just develops random features. | [reply] |
by Anonymous Monk on Jan 26, 2003 at 20:52 UTC | |
Use "Data::Type" instead (was Data::Verify). - Now "quite" stable api (alpha). - 90% of your requested "value types" - Documentation extended. - Added more tests. | [reply] |
|
Re: Data Validation Tests
by Aragorn (Curate) on Jan 26, 2003 at 11:42 UTC | |
The terms strong cohesion and loose coupling spring to mind. Functions for validating data should be part of the module processing that data. Having a separate module with all kinds of unrelated validation routines increases the risk of (possibly) not keeping up with changes in the format, and I don't really need credit card number validation routines in my logfile processing script which extracts IP addresses. Arjen | [reply] [d/l] |
by Aristotle (Chancellor) on Jan 26, 2003 at 14:09 UTC | |
Even if you replace the regex by ID::validate(), the whole thing remains rather clunky - esp if you imagine that you have to write such a snippet for 25 different parameters: pure drone work. It is much easier to use a Data::FormValidatoresque declaration like
While this doesn't compare favourably so far, adding more parameters to validate would be trivial and quick with the latter code. Adding another two dozen checks is easy and doesn't result in an unmanageable amount of code. I do agree that the validator should not contain its own actual validation routines. That's why I don't like Data::FormValidator as is; I would prefer there being plugin modules that integrate other modules' own supplied validation routines - much the way File::Find::Rule works. Makeshifts last the longest. | [reply] [d/l] [select] |
by Flame (Deacon) on Jan 26, 2003 at 15:32 UTC | |
My code doesn't have bugs, it just develops random features. | [reply] |
by perrin (Chancellor) on Jan 26, 2003 at 17:58 UTC | |
by Flame (Deacon) on Jan 26, 2003 at 19:40 UTC | |
|
Re: Data Validation Tests
by Abigail-II (Bishop) on Jan 26, 2003 at 23:56 UTC | |
But doing validation is a lot harder than you think. You need to find authorative documentation (there are many, many URI schemes, there are only a few URI schemes that have RFC that aren't either ambiguous, unclear from which conflicting RFCs they import terms, or defined in superceeded RFCs - but not in the superseeding RFC itself. A lot of schemes are only documented in internet drafts, of which the latest has expired years ago), and regexes are hard to test right. You have to consider lots of cases, and combinations of cases, and also a lot of cases where the regex should fail. Two weeks ago, I redid the test suite for http URIs, which is actually one of the better defined URI schemes, and it took me two full nights to get it all working. It did turn up a few bugs as well. I've wanted to add dates to Regexp::Common for quite some time as well, but were do you start? There are so many forms to choose from. Perhaps start with dates in ISO format? It sounds simple, until you actually read the 33 page specification. Email addresses.... Once, they will be part of Regexp::Common. I've done them using Parse::RecDescent (in RFC::RFC822::Address), and it won't be a pretty regex, as it will be recursive. I haven't had the guts to do this beast yet. I don't think valid credit card numbers would be hard - but I lack their specification. If you can provide me with it, I'll add it to Regexp::Common (but the spec should be better than "a 14 digit number"). Send me regexes and specifications, preferably with an extensive test suite, and I'll add it to Regexp::Common (current version: 2.104, 87 patterns in 11 classes, 156778 tests in 30 files). Abigail | [reply] |
by Cody Pendant (Prior) on Jan 27, 2003 at 00:28 UTC | |
Actually even that would be wrong. The spec for credit cards includes 13- to 16-digit numbers as well. The spec would be, roughly, "a 13-to-16-digit Luhn number beginning with one of a list of prefixes."
There's an article about it here and a Perl implementation for checking here | [reply] |
|
Why reinvent the wheel?
by autarch (Hermit) on Jan 27, 2003 at 04:29 UTC | |
Please, before you release yet another redundant module (YARM), please consider whether not what you want wouldn't be better done as patches to existing modules, including, but not limited to ... Params::ValidateData::Verify Data::FormValidator Data::Validator::Item Class::ParamParser & Class::ParmList Getargs::Long Plus related modules like Regexp::Common, Email::Valid, Business::CreditCard, and more. Yes, your proposed API is somewhat different from the existing offerings. But is it so different that it offers completely unique functionality? I don't think so. In fact, it seems fairly close to Data::Validator::Item. One of the big problems with CPAN is that people just go ahead and upload more and more modules that basically do the same thing as everything else, just with a different API. Some categories are overwhelmingly full (DBI wrappers, for example). Parameter validation isn't quite at the point yet, but it's getting close. If there's something you really want that doesn't exist, pick the existing module you like best, and offer the author patches. If that doesn't work out, then consider creating your own module. | [reply] |
by Flame (Deacon) on Jan 27, 2003 at 04:40 UTC | |
Thank you for the advice. Even if this is eventually rejected by the community as a whole, it will still be practice, and another opportunity to expand my skill with perl. (Flame: Remembers 2 "OOh, what does THIS do"'s that occured during the development up to this point) Edit: Oh, I would like to know what similaities you see between this and Data::Validator::Item My code doesn't have bugs, it just develops random features. | [reply] |
by Anonymous Monk on Jan 27, 2003 at 12:08 UTC | |
| [reply] [d/l] |
|
Re: Data Validation Tests
by demerphq (Chancellor) on Jan 28, 2003 at 14:58 UTC | |
You should be aware that this date format is particularly nonstandard and difficult to check. Use of ISO date formats YYYY/MM/DD or similar should be standard practice for all professional programmers. In fact I would even go so far as to suggest that a programmer that blindly allows DD/MM/YYYY even at the request of a client is doing the client a disservice. ISO standards and their relatives (DIN for example specifies the same format) are there for a reason. Incidentally to back this claim up consider that MM/DD/YYYY and DD/MM/YYYY are both popular written date formats. Unfortunately there is no way to determine if 02/03/2003 is the third of Febuary or the second of March. There is no such ambiguity in YYYY/MM/DD. (Or if there is I would argue it is of signifigantly less likelyhood of occuring.)
--- demerphq | [reply] |
by Flame (Deacon) on Jan 28, 2003 at 21:52 UTC | |
| [reply] | |
|
Re: Data Validation Tests
by shotgunefx (Parson) on Jan 27, 2003 at 01:30 UTC | |
For int, float, other numbers, it could be used to make sure they are within a given range. For date types that the time is within a given period. For text that the length is within the allowed limits. Also I would add TEXT and ALPHANUMERIC /^\w-+$/ to your type list. -Lee "To be civilized is to deny one's nature." | [reply] |
|
Re: Data Validation Tests
by hsmyers (Canon) on Jan 29, 2003 at 19:39 UTC | |
Given the amount of time I hang-out in book space, I would have liked to see something along these lines for ISBN numbers. When last I checked CPAN there was at least one solution (more actually) but most required something along the lines of use Kitchen::Sink; so after a bit of looking around I came up with: Don't know if this is what you had in mind, but I found it useful... --hsm "Never try to teach a pig to sing...it wastes your time and it annoys the pig." | [reply] [d/l] |
by Flame (Deacon) on Jan 29, 2003 at 22:35 UTC | |
| [reply] | |