<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[
Zend_CheckDigit is a utility class to provide access to creation of check digits and validation using various check digit algorithms. Additional algorithms that might be considered include: Some other notes:Zend Framework: Zend_CheckDigit Component Proposal
Proposed Component Name
Zend_CheckDigit
Developer Notes
http://framework.zend.com/wiki/display/ZFDEV/Zend_CheckDigit
Proposers
Steven Brown
Revision
0.1 - 7 February 2008: Created.
0.2 - 9 February 2008: Added more algorithms due to community request (wiki revision: 13)Table of Contents
1. Overview
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
4. Dependencies on Other Framework Components
- Zend_Exception
5. Theory of Operation
In the fashion of existing Zend Framework components a class might be created for each algorithm. The base Zend_CheckDigit class might have static functions to return the class for a specific algorithm.
It might be useful to create an interface for each algorithm with the following methods:
- generate($number) will return the check digit (int)
- append($number) will return the original number with the check digit added to the end
- isValid($number) will return a boolean, true if the check digit contained within $number is correct, false if it is not
It is assumed that the check digit will always be the last digit for isValid, unless the algorithm follows another structure. It would also be possible for append to return a formatted number for algorithms such as ISBN, although this might use a seperate format($number) method.
6. Milestones / Tasks
- Milestone 1: Design notes...whatever they are
- Milestone 2: Working prototype checked into the incubator supporting use cases
- Milestone 3: Unit tests exist, work, and are checked into SVN.
- Milestone 4: Initial documentation exists.
7. Class Index
- Zend_CheckDigit (factory class)
- Zend_CheckDigit_Exception (maybe used when a number is not properly formatted?)
- Zend_CheckDigit_Luhn
- Zend_CheckDigit_Verhoeff
- Zend_CheckDigit_Code39
- Zend_CheckDigit_Code128
- Zend_CheckDigit_Isbn10
- Zend_CheckDigit_Isbn13
- Zend_CheckDigit_Ean13
- Zend_CheckDigit_Upc
It may be possible to merge ISBN-10 and ISBN-13 however this may cause issues with length validation. Code128 might need to be split into A, B and C though it should be possible to keep it as one and use the first character to determine with character set is being used. It may be necessary to specify UPC as UPC-A since other formats do exist but are apparently mostly redundant.
Additional classes may be added depending on algorithms that are implemented, such as:
- Zend_CheckDigit_Vin
- Zend_CheckDigit_LuhnModN
- Zend_CheckDigit_Ean8
8. Use Cases
Instantiate class:
Generate check digit:
Validate check digit:
4 Comments
comments.show.hideMay 13, 2008
Wil Sinclair
<p>Steven, is this proposal ready for community review? I noticed that the 'under construction' note is gone, but it is still in the 'new' section. Please update it as necessary.</p>
<p>Thanks.<br />
,Wil</p>
Jun 18, 2008
Matthew Ratzloff
<p>Is there any way to make this part of Zend_Validate?</p>
Jun 20, 2008
Wil Sinclair
<p>What is the status of this proposal? Is it still active?</p>
<p>,Wil</p>
Jul 10, 2008
Steven Brown
<p>I no longer have a need for this functionality, unless there is a community need I don't think I would continue with it.</p>