Skip to content

Instantly share code, notes, and snippets.

@apipkin
Created February 25, 2010 19:03
Show Gist options
  • Save apipkin/314915 to your computer and use it in GitHub Desktop.
Save apipkin/314915 to your computer and use it in GitHub Desktop.
<?php
// Zend Form Snippet
// custom error message with Regex Validator
$this->addElement(new Zend_Form_Element_Text('phone_number'));
$this->getElement('phone_number')
->setLabel('Phone Number')
->setRequired(true)
->addValidators(array(
array(
'validator' => 'Regex',
'breakChainOnFailure' => true,
'options' => array(
'pattern' => '/^[+]?[-\d() .]*$/i',
'messages' => array(
Zend_Validate_Regex::NOT_MATCH =>'Please provide a valid Phone Number.'
)
)
),
array(
'validator' => 'StringLength',
'breakChainOnFailure' => true,
'options' => array(
'min' => 10
)
)
))
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment