compared with
Version 3 by Thomas Weidner
on Jun 11, 2009 05:27.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (19)

View Page History

{zone-data:operation}
The component is instantiated with a mind-link that ...
The component validates if a given string conforms a expected input. The expected format can be a national number, a international number, or a self defined format. It can also check if number parts are given. (country code, extension).
{zone-data}

{zone-data:milestones}
Describe some intermediate state of this component in terms of design notes, additional material added to this page, and / code. Note any significant dependencies here, such as, "Milestone #3 can not be completed until feature Foo has been added to ZF component XYZ." Milestones will be required for acceptance of future proposals. They are not hard, and many times you will only need to think of the first three below.
* Milestone 1: [design notes will be published here|http://framework.zend.com/wiki/x/sg]
* Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
* Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
* Milestone 1: \[DONE\] Proposal finished
* Milestone 2: Proposal accepted
* Milestone 3: Working implementation
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists. Documentation

If a milestone is already done, begin the description with "\[DONE\]", like this:
* Milestone #: \[DONE\] Unit tests ...
* Milestone 6: Moved to core
{zone-data}

{zone-data:class-list}
* Zend_Magic_Exception Zend_Validate_Phone
* Zend_Magic (factory class)
* Zend_Magic_MindProbe
* Zend_Magic_MindProbe_Intent
* Zend_Magic_Action
* Zend_Magic_CodeGen
{zone-data}

{zone-data:use-cases}
||UC-01||
Simply validation... accepts all sorts of phone numbers
{code}
$validate = new Zend_Validate_Phone();
$validate->isValid('(123) 456789');
$validate->isValid('+49 (123) 456789');
$validate->isValid('0049 123 456789-123');
$validate->isValid('456789 - 123');
$validate->isValid('Phone: 456 - 132'); // FALSE
{code}

... (see good use cases book)
||UC-02||
Validation for one country
{code}
$validate = new Zend_Validate_Phone('de_AT');
$validate->isValid('(1234) 56789');
$validate->isValid('+49 (123) 456789'); // FALSE
$validate->isValid('0049 123 456789-123'); // FALSE
$validate->isValid('0043 123 456789-123');
$validate->isValid('456789 - 123');
$validate->isValid('Phone: 456 - 132'); // FALSE
{code}

||UC-02||
Validation with set options (no extension)
{code}
$validate = new Zend_Validate_Phone(array('locale' => 'de_AT', 'format' => Zend_Validate_Phone::NO_EXTENSION));
$validate->isValid('(1234) 56789');
$validate->isValid('+49 (123) 456789'); // FALSE
$validate->isValid('0049 123 456789-123'); // FALSE
$validate->isValid('0043 123 456789-123'); // FALSE because of extension
$validate->isValid('456789 - 123'); // FALSE
$validate->isValid('456789'); // FALSE
$validate->isValid('Phone: 456 - 132'); // FALSE
{code}

||UC-03||
Validation with set options (national format)
{code}
$validate = new Zend_Validate_Phone(array('locale' => 'de_AT', 'format' => Zend_Validate_Phone::NATIONAL));
$validate->isValid('(1234) 56789');
$validate->isValid('+49 (123) 456789'); // FALSE
$validate->isValid('0049 123 456789-123'); // FALSE
$validate->isValid('0043 123 456789-123'); // FALSE because of international format
$validate->isValid('456789 - 123');
$validate->isValid('Phone: 456 - 132'); // FALSE
{code}

||UC-04||
Validation with self defined format
{code}
$validate = new Zend_Validate_Phone(array('locale' => 'de_AT', 'format' => array('TCN' => 4, 'CCN' => 3, 'LCN' => '5-7', 'EXT' => 0)));
{code}
The resulting number would be like
Territory code: 4 numbers
City code: 3 numbers
Local code: 5 to 7 numbers
Extension: 0 numbers

+49 1234 456789 -> false -> territory code 2 and not 4
0049 (1234) 456789 -> true
0049 (1234) 456789-123 -> false, extension given
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Magic_Exception extends Zend_Exception {}
class Zend_Validate_Phone extends Zend_Validate_Abstract {}

class Zend_Magic {
const NATIONAL;
const INTERNATIONAL;
const NO_EXTENSION;
...
public function __construct($parameters);
public function getTerritory();
public function setTerritory($territory);
public function getFormat();
public function setFormat($format);
public function isValid($input);
}
{code}
{zone-data}