think\console\output\Question::getValidator PHP Method

getValidator() public method

获取验证器
public getValidator ( ) : null | callable
return null | callable
    public function getValidator()
    {
        return $this->validator;
    }

Usage Example

Ejemplo n.º 1
0
 protected function validateAttempts($interviewer)
 {
     /** @var \Exception $error */
     $error = null;
     $attempts = $this->question->getMaxAttempts();
     while (null === $attempts || $attempts--) {
         if (null !== $error) {
             $this->output->error($error->getMessage());
         }
         try {
             return call_user_func($this->question->getValidator(), $interviewer());
         } catch (\Exception $error) {
         }
     }
     throw $error;
 }