Ejemplo n.º 1
0
 /**
  * @param string $rawvalue the user to validate
  * @return int|string|void
  */
 public function validate($rawvalue)
 {
     $rawvalue = parent::validate($rawvalue);
     if ($this->config['existingonly']) {
         /** @var \DokuWiki_Auth_Plugin $auth */
         global $auth;
         $info = $auth->getUserData($rawvalue, false);
         if ($info === false) {
             throw new ValidationException('User not found', $rawvalue);
         }
     }
     return $rawvalue;
 }
Ejemplo n.º 2
0
 /**
  * @param int|string $rawvalue
  * @return int|string
  * @throws ValidationException
  */
 public function validate($rawvalue)
 {
     $rawvalue = parent::validate($rawvalue);
     $rawvalue = str_replace(',', '.', $rawvalue);
     // we accept both
     if ((string) $rawvalue != (string) floatval($rawvalue)) {
         throw new ValidationException('Decimal needed');
     }
     if ($this->config['min'] !== '' && floatval($rawvalue) <= floatval($this->config['min'])) {
         throw new ValidationException('Decimal min', floatval($this->config['min']));
     }
     if ($this->config['max'] !== '' && floatval($rawvalue) >= floatval($this->config['max'])) {
         throw new ValidationException('Decimal max', floatval($this->config['max']));
     }
     return $rawvalue;
 }