Skip to content

Instantly share code, notes, and snippets.

@sebastianhoitz
Created May 13, 2011 21:41
Show Gist options
  • Save sebastianhoitz/971363 to your computer and use it in GitHub Desktop.
Save sebastianhoitz/971363 to your computer and use it in GitHub Desktop.
Zend PostCode Validator dependent on Country
<?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