Prompt user for input untill the given input returns true from the
validation callback function.

@param string $prompt the prompt message
@param callable $validationCallback
@return $result user input that passed validation
430017
public function askUntillValid(string $prompt, callable $validationCallback)
    {
        $result = null;

        while($validationCallback($result) !== true) {
            $result = $this->readLine("$prompt");
        }
        return $result;
    }
442874
private static function _checkCallback($cls, $callback, $context)
    {
        self::_initiateCallbacks($cls);
        foreach (self::$_callbacks[$cls][$callback] as $func) {
            if (!call_user_func(array($context, $func))) {
                return false;
            }
        }
        return true;
    }
748423
protected static function prepareCallbackPrompter(
        CallbackPrompter $prompter,
        $noValidMessage,
        $attemptTimes,
        $failCloseMessage
    ) {
        $prompter->setAttemptTimes($attemptTimes);

        if ($noValidMessage !== null) {
            $prompter->setNoValidMessage($noValidMessage);
        }

        if ($failCloseMessage !== false) {
            $prompter->failToClose(true, $failCloseMessage);
        }

        return $prompter;
    }
274625
private function validate_helper_input( $helper ) {
		if ( ! is_array( $helper ) || empty( $helper ) ) {
			return false;
		}

		if ( !  isset( $helper[ 'name' ] ) || ! isset( $helper[ 'class' ]  ) ) {
			return false;
		}

		//if not set, set callback name to "helper"
		if ( ! isset( $helper[ 'callback' ] ) ) {
			$helper[ 'callback' ] = 'helper';
		}

		return $helper;

	}
1028221
public function ask($name, $prompt, $default = '', $required = false)
    {
        $this->questions[$name] = [
            'prompt' => $prompt,
            'default' => $default,
            'required' => $required,
        ];
    }
791372
public function password(string $prompt)
    {
        if ($this->style) {
            echo $this->formatter->getStartMark($this->style);
        }

        $result = $this->console->readPassword($prompt);

        if ($this->style) {
            echo $this->formatter->getClearMark();
        }

        return $result;
    }
128400
public static function prompt()
    {
        $stdin = fopen('php://stdin', 'r');
        $answer = self::trimAnswer(fgets($stdin, 4096));
        fclose($stdin);

        return $answer;
    }
449577
public function confirm(string $prompt, bool $yes = null): bool
    {
        $default = null;
        if ($yes === true) {
            $default = 'Y';
        } elseif ($yes === false) {
            $default = 'n';
        }

        return 'Y' === $this->ask($prompt, ['Y', 'n'], $default);
    }
973135
private function validate($hash, string $validation_regex): void {
    if(!is_string($hash) || preg_match($validation_regex, $hash) === 0) {
      throw new InvalidArgumentException('Expected hash, but got ' . var_export($hash, true) . '] instead');
    }
  }
1203745
protected function withErrorBag($errorBag, callable $callback)
    {
        $this->validatesRequestErrorBag = $errorBag;

        call_user_func($callback);

        $this->validatesRequestErrorBag = null;
    }
502582
public function validate(AbstractValidator $validator, $removeRequired = false, array $messages = [], array $customAttributes = [])
    {
        return $validator->validate($removeRequired);
        /*try {
            return $validator->validate($removeRequired);
        } catch (ValidationException $e) {
            $this->throwValidationException($e->getErrors());
        }*/

//              $this->throwValidationException($request, $validator);
        // $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);

    }
519302
public function prompt()
    {
        $this->writePrompt();

        $response = $this->valueOrDefault($this->getUserInput());

        if ($this->isValidResponse($response)) {
            return $response;
        }

        return $this->prompt();
    }
1269571
private function input() {
		if ($this->input===null) {
			$this->input=new ValidationInputOne($this->prefix,$this->messageList); // we used the same message list
		}
		return $this->input;
	}
136561
public function ValidateUserInput()
    {
        $bIsValid = parent::ValidateUserInput();

        if ($bIsValid) {
            $oMsgManager = TCMSMessageManager::GetInstance();

            $aDefaultVals = $this->GetDefaultUserPaymentData();

            foreach (array_keys($aDefaultVals) as $sField) {
                if (!array_key_exists($sField, $this->aPaymentUserData) || empty($this->aPaymentUserData[$sField])) {
                    $oMsgManager->AddMessage(self::MSG_MANAGER_NAME.'-'.$sField, 'ERROR-USER-REQUIRED-FIELD-MISSING');
                    $bIsValid = false;
                }
            }
        }

        return $bIsValid;
    }
461931
def prompt_for_input(message, input_type=None):
    """"""
    while True:
        output = prompt.query(message)

        if input_type:
            try:
                output = input_type(output)
            except ValueError:
                error_message('Invalid input type')
                continue

        break

    return output
458513
function validateInput( $http, $base,
                            &$inputParameters, $validationParameters = array() )
    {
        $dataType = $this->dataType();
        if ( $dataType )
        {
            $this->setInputParameters( $inputParameters );
            $this->setValidationParameters( $validationParameters );
            $this->IsValid = $dataType->validateObjectAttributeHTTPInput( $http, $base, $this );
            $this->unsetValidationParameters();
            $this->unsetInputParameters();
        }
        return $this->IsValid;
    }
1112479
def regexp_prompt(prompt, regexp='.', answer=''):
    '''
    
    '''
    get_input = getattr(__builtins__, 'raw_input', input)
    while not re.search(regexp, answer):
        answer = get_input(prompt + ': ').strip()
        # If the option isn't valid, this is shown next
        message = "Your entry must match the regular expression %s" %regexp    

    return answer