<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Fields_Form_Element_ZipCode extends Engine_Form_Element_Text
{
  public function init()
  {
    $this->addValidator('Regex', true, array(
      '/^([0-9]{3,6})$|^([0-9]{5}-[0-9]{4})$|^([a-zA-Z0-9]{1,2}[0-9]{1,4})$|^([a-zA-Z0-9]{2,4}\s[a-zA-Z0-9]{2,4})$|^([a-zA-Z0-9]{1,3}-[a-zA-Z0-9]{2,4})$/'
      ));
    // Fix messages
    $this->getValidator('Regex')->setMessage("'%value%' is not a valid zip code.", 'regexNotMatch');
  }
}
