Initial Commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
class App_Form_Validators_EmailPec extends Zend_Validate_Abstract
|
||||
{
|
||||
const EMAIL_NULL='is_empty';
|
||||
const EMAIL_ISPEC='is_pec';
|
||||
private $_PEC_DOMAINS = array('pec.it','arubapec.it','legalmail.it');
|
||||
|
||||
|
||||
protected $_messageTemplates = array(
|
||||
self::EMAIL_NULL=>'Valore non presente ',
|
||||
self::EMAIL_ISPEC=>"L'Email inserita sembra essere una PEC, si prega di inserire un email privata"
|
||||
);
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
$this->_setValue($value);
|
||||
|
||||
$isValid = true;
|
||||
|
||||
if ($value === ''){
|
||||
$this->_error(self::EMAIL_NULL);
|
||||
$isValid = false;
|
||||
}
|
||||
|
||||
$domain = explode('@',$value);
|
||||
$domain = $domain[1];
|
||||
|
||||
if(in_array($domain,$this->_PEC_DOMAINS)){
|
||||
$this->_error(self::EMAIL_ISPEC);
|
||||
$isValid = false;
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user