Created
May 13, 2011 21:41
-
-
Save sebastianhoitz/971363 to your computer and use it in GitHub Desktop.
Zend PostCode Validator dependent on Country
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class My_Validate_PostCode extends Zend_Validate_Abstract | |
{ | |
public function isValid($value, $context = null) | |
{ | |
$value = (string) $value; | |
if(!(is_array($context) && isset($context['country']))) | |
{ | |
return true; | |
} | |
$country = $context['country']; | |
$locale = Zend_Locale::getLocaleToTerritory($country); | |
$validator = new Zend_Validate_PostCode($locale); | |
return $validator->isValid($value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment