function createFormatValidator($regex, $valid_symbols) { require_once 'Validation/FormatValidator.php'; $validator = new FormatValidator(); $validator->setRegex($regex); $validator->setValidSymbols($valid_symbols); return $validator; }
function validate(&$obj, &$field, &$fields) { if (isset($fields[$field]) && $fields[$field]->value != "") { switch ($this->_istype) { case FormatValidator::IS_ALNUM: return ctype_alnum($fields[$field]->value); case FormatValidator::IS_ALPHA: return ctype_alpha($fields[$field]->value); case FormatValidator::IS_CREDITCARD: return false; case FormatValidator::IS_DATE: return false; case FormatValidator::IS_DIGITS: return false; case FormatValidator::IS_EMAIL: return FormatValidator::isEmail($fields[$field]->value); case FormatValidator::IS_FLOAT: return false; case FormatValidator::IS_HEX: return ctype_xdigit($fields[$field]->value); case FormatValidator::IS_HOSTNAME: return false; case FormatValidator::IS_INT: return false; case FormatValidator::IS_PHONE: return false; case FormatValidator::IS_URI: return false; case FormatValidator::IS_ZIP: return false; case FormatValidator::IS_ALNUM_SPACE: return ctype_alnum(str_replace(" ", "", $fields[$field]->value)); } } else { return true; } }