Hi Darby,

I know that the Australian BPAY system when I implemented it a few years ago
required generation of order numbers with a check digit attached. There were
several algorithms to choose from but ofcourse the Luhn is not a bad option.

I am also currently working on a system where customer numbers and affiliate
IDs are generated and check digits will be a nice simple addition to ensure
people enter these correctly.

Verhoeff is just an alternative to Luhn in these examples. Any accounts
system could benefit from check digits for account numbers, invoice numbers,
product numbers etc.

My point generally with these algorithms and the card type detection is that
while the Validate classes are certainly valuable, a Validate class is
probably not technically the correct place for these "utilities" to exist.
Perhaps a Zend_Util_Luhn or Zend_Math_Luhn or other grouping name might
allow not only these but many other utilities to exist without needing a
specific application, instead specific applications (such as Validate) can
be built to use these classes.

I know there is a discussion at the moment regarding ZF packaging that may
be along a similar line to what I am talking about.

Cheers,
Steven

-----Original Message-----
From: Darby Felton [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 6 February 2008 1:12 AM
To: Steven Brown
Cc: 'Zend Framework General'
Subject: Re: [fw-general] Addition of utility classes to ZF

Hi Steven,

Steven Brown wrote:
> Hi Darby,
> 
> The Zend_Validate_Ccnum is only one application of the Luhn algorithm, I
> would have thought the Luhn class would be separate from the Validate
class?

I suppose it could be separated easily enough. In fact, the Ccnum
validator does barely more than ensuring the Luhn algorithm is followed
for the digits of the input (it ensures the number of digits is between
13 and 19, no big deal). Probably the Ccnum validator would simply make
use of the new Luhn validator.

> There is an application to generate check digits for account numbers etc.
> The same applies to Verhoeff, validation is not the only purpose.

For what application(s) are you wishing to use a separate Luhn
validator, I'm curious? For account numbers? What kinds of accounts?

In any case, you can file a JIRA issue for this and, if you're willing,
make these contributions yourself (of course I am happy to help!):

http://framework.zend.com/issues/secure/CreateIssue!default.jspa

http://framework.zend.com/community/contribute/

By validation I simply mean that:

* input is checked against some criteria

* the validator returns a boolean, whether or not the input satisfy the
criteria

* the validator also provides the reason(s) for validation failure,
should the input not satisfy the criteria

How might your use case differ from this?

> On the note of the Zend_Validate_Ccnum class, what if we wanted to
> automatically detect what credit card was being used (based on
> numbers/length)? While Zend_Validate_Ccnum would be good for ensuring a
card
> is a particular type (and that the check digit is correct) is this the
place
> for code to figure out what the card type is?

I don't know of a better place offhand, but I'm open to suggestions. I
can imagine that the Ccnum validator could recognize what type of card
was being used and provide this information separately. For example:

$ccnumValidator = new Zend_Validate_Ccnum();
if (!$ccnumValidator->isValid($ccnum)) {
    // validation failed; see $ccnumValidator->getMessages()
} else {
    // validation passed; get the card brand
    echo $ccnumValidator->getCardBrand(); // prints "VISA" or something
}

> Sorry if this is obvious to everyone else but it seems to me that there is
> need for a utility class area to feed things like validation, but also be
> used elsewhere.

I'm not sure exactly what you're suggesting. What utilities do you think
we need to add and where?

Thanks!

Best regards,
Darby

> 
> Cheers,
> Steven
> 
> -----Original Message-----
> From: Darby Felton [mailto:[EMAIL PROTECTED] 
> Sent: Friday, 1 February 2008 11:24 PM
> To: Steven Brown
> Cc: 'Zend Framework General'
> Subject: Re: [fw-general] Addition of utility classes to ZF
> 
> Hi Steven,
> 
> We have an implementation of the Luhn algorithm within
> Zend_Validate_Ccnum, though I'm pretty sure we have not implemented the
> Verhoeff algorithm anywhere. (Please correct me if I'm wrong, anyone.)
> 
> I think that such validation may fit nicely into the Zend_Validate
> "namespace", but if you are interested in contributing this and other
> utilities to Zend Framework, please see:
> 
> http://framework.zend.com/community/contribute
> 
> for more information. Probably it would be good to describe the
> utilities and getting some more feedback before making any judgment
> about whether they would be worth including. :)
> 
> There is also a proposal process for making ZF contributions:
> 
> http://framework.zend.com/wiki/display/ZFPROP/Home
> 
> Thank you for your interest in contributing to Zend Framework! :)
> 
> Best regards,
> Darby
> 
> Steven Brown wrote:
>> Hi all,
>>
>> I was just about to create some utility classes for Luhn (MOD10) and
>> Verhoeff check digit generation and checking. Is this the kind of thing
> that
>> might fit into ZF somewhere and if so where?
>>
>> There are a whole heap of utility classes I use outside of ZF that are
>> sometimes incompatible or not in the coding standard of ZF, is there much
>> point in converting these and contributing them to ZF?
>>
>> Cheers,
>> Steven
>>
>>
>>
> 
> 
> 


Reply via email to