/**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     // Test the check digit
     $matches = $this->getMatches();
     $issn = $matches[1] . $matches[2];
     $check = 0;
     for ($i = 0; $i < 7; $i++) {
         $check += $issn[$i] * (8 - $i);
     }
     $check = $check % 11;
     switch ($check) {
         case 0:
             $check = '0';
             break;
         case 1:
             $check = 'X';
             break;
         default:
             $check = (string) (11 - $check);
     }
     return $issn[7] === $check;
 }
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     // Test the check digit
     // ORCID is an extension of ISNI
     // http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
     $matches = $this->getMatches();
     $orcid = $matches[1] . $matches[2] . $matches[3] . $matches[4];
     import('lib.pkp.classes.validation.ValidatorISNI');
     $validator = new ValidatorISNI();
     return $validator->isValid($orcid);
 }
Пример #3
0
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     // Test the check digit
     $matches = $this->getMatches();
     $issn = $matches[1] . $matches[2];
     $check = 0;
     for ($i = 0; $i < 7; $i++) {
         $check += $issn[$i] * (8 - $i);
     }
     return (int) $issn[7] == 11 - $check % 11;
 }
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     $matches = $this->getMatches();
     $match = $matches[0];
     $total = 0;
     for ($i = 0; $i < 15; $i++) {
         $total = ($total + $match[$i]) * 2;
     }
     $remainder = $total % 11;
     $result = (12 - $remainder) % 11;
     return $match[15] == ($result == 10 ? 'X' : $result);
 }
Пример #5
0
 /**
  * @see ValidatorRegExp::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     // Retrieve the matches from the regexp validator
     $matches = $this->getMatches();
     // Check IPv4 address validity
     if (!empty($matches[4])) {
         $parts = explode('.', $matches[4]);
         foreach ($parts as $part) {
             if ($part > 255) {
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     $dateMatches = $this->getMatches();
     if (isset($dateMatches['month'])) {
         if ($dateMatches['month'] >= 1 && $dateMatches['month'] <= 12) {
             if (isset($dateMatches['day'])) {
                 return checkdate($dateMatches['month'], $dateMatches['day'], $dateMatches['year']);
             } else {
                 return true;
             }
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
Пример #7
0
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     // Test the check digit
     // Based on the ORCID checksum at:
     // http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
     $matches = $this->getMatches();
     $orcid = $matches[1] . $matches[2] . $matches[3] . $matches[4];
     $total = 0;
     for ($i = 0; $i < 15; $i++) {
         // convert X to 10
         if ($orcid[i] == "X") {
             $orcid[i] = 10;
         }
         $total += $orcid[$i] * 2;
     }
     $remainder = $total % 11;
     $result = (12 - $remainder) % 11;
     return $orcid[15] == $result ? "X" : $result;
 }
Пример #8
0
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @param $minScope int The minimum date resolution allowed, e.g. VALIDATOR_DATE_SCOPE_MONTH will allow YYYY-MM or YYYY-MM-DD, but not YYYY
  * @param $maxScope int The maximum date resolution allowed, e.g. VALIDATOR_DATE_SCOPE_MONTH will allow YYYY or YYYY-MM, but not YYYY-MM-DD
  * @return boolean
  */
 function isValid($value, $minScope = VALIDATOR_DATE_SCOPE_YEAR, $maxScope = VALIDATOR_DATE_SCOPE_DAY)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     if ($minScope < $maxScope) {
         return false;
     }
     $dateMatches = $this->getMatches();
     if (isset($dateMatches['month'])) {
         if ($dateMatches['month'] >= 1 && $dateMatches['month'] <= 12 || $maxScope == VALIDATOR_DATE_SCOPE_YEAR) {
             if (isset($dateMatches['day'])) {
                 return checkdate($dateMatches['month'], $dateMatches['day'], $dateMatches['year']) && $maxScope == VALIDATOR_DATE_SCOPE_DAY;
             } else {
                 return $maxScope < VALIDATOR_DATE_SCOPE_YEAR && $minScope > VALIDATOR_DATE_SCOPE_DAY;
             }
         } else {
             return false;
         }
     } else {
         return $minScope == VALIDATOR_DATE_SCOPE_YEAR;
     }
 }
Пример #9
0
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     if (!parent::isValid($value)) {
         return false;
     }
     // Test the check digit
     // Based on the ORCID checksum at:
     // http://support.orcid.org/knowledgebase/articles/116780-structure-of-the-orcid-identifier
     $matches = $this->getMatches();
     $orcid = $matches[1] . $matches[2] . $matches[3] . $matches[4];
     $total = 0;
     for ($i = 0; $i < 15; $i++) {
         $digit = (int) $orcid[$i];
         $total = ($total + $digit) * 2;
     }
     $remainder = $total % 11;
     $result = (12 - $remainder) % 11;
     $checkDigit = $result == 10 ? 'X' : $result;
     if ($checkDigit == $orcid[15]) {
         return true;
     }
     return false;
 }
Пример #10
0
 /**
  * Constructor.
  */
 function ValidatorEmail()
 {
     parent::ValidatorRegExp(ValidatorEmail::getRegexp());
 }
 /**
  * Constructor.
  */
 function __construct()
 {
     parent::__construct(ValidatorEmail::getRegexp());
 }