A helper function for getting user input
@param {string} question The question to be asked
@param {string} validValues Typically a regex or array
@param {string} message The validation message
@returns {string} the user input
337311
function ask(question, validValues, message) {
  readline.setDefaultOptions({
    limit: validValues,
    limitMessage: message
  });
  return readline.question(question);
}
894865
public static boolean checkContainsInvalidCharacter(String text, String invalidCharacters){
		if(text == null || text.trim().length() == 0 || invalidCharacters == null) return false;
		
		for (char c : invalidCharacters.toCharArray()) {
			if(text.indexOf(new String(new char[]{c})) >= 0) return true;
		}
		
		return false;
	}
610257
private static void validateMessageText(String messageML) throws InvalidInputException {
    if (messageML == null) { throw new InvalidInputException("Message input is NULL"); }

    for (char ch : messageML.toCharArray()) {
      if (ch != '\n' && ch != '\r' && ch != '\t' && (ch < ' ')) {
        throw new InvalidInputException("Invalid control characters in message");
      }
    }
  }
1219695
public String getInvalidMessage(String key) {
        return invalidMessageOverride == null ? messageMixin.lookup(key, messageValueArgs) : MessageFormat.format(
                invalidMessageOverride, messageValueArgs);
    }
429606
function assert(actual, expected, message) {
  if (toString.call(expected) === '[object RegExp]' && expected.test(actual)) {
    return;
  } else if (eql(actual, expected)) {
    return;
  }

  var pad = Array(5).join(' ');
  var msg = message + '\n\n'
    + pad + 'Actual:   ' + inspect(actual) + '\n'
    + pad + 'Expected: ' + inspect(expected) + '\n';

  return new AssertionError(msg, {
    actual: actual,
    expected: expected,
    showDiff: assert.showDiff
  });
}
848172
function isSituationalChessMessage(msg) {
    if (!msg.value || !msg.value.content) {
      return false;
    }

    const relevantMessageTypes = [
      'chess_invite',
      'chess_invite_accept',
      'chess_move',
      'chess_game_end'];

    const messageType = msg.value.content.type;
    const isSituationMsg = relevantMessageTypes.find(m => m === messageType);
    return isSituationMsg !== undefined;
  }
163937
public function askInput($questionText, $default = null, array $autoCompleterValues = [], callable $validator = null)
    {
        if ($default !== null) {
            $questionText .= ' <question>[' . $default . ']</question>';
        }
        $questionText .= ': ';
        $question = new Question($questionText, $default);
        if (!empty($autoCompleterValues)) {
            $question->setAutocompleterValues($autoCompleterValues);
        }
        if ($validator !== null) {
            $question->setValidator($validator);
            $question->setMaxAttempts(5);
        }

        return $this->ask($this->input, $this->output, $question);
    }
1332006
function ( message, parameters ) {
			return message.replace( /\$(\d+)/g, function ( str, match ) {
				var index = parseInt( match, 10 ) - 1;
				return parameters[index] !== undefined ? parameters[index] : '$' + match;
			} );
		}
322593
function validateForm() {

            var isValid = isEmpty(errors);

            formData = {};

            $.each(
                node.find('input:not([type="submit"]), select, textarea').not(':disabled'),
                function(index, input) {

                    input = $(input);

                    var value = _getInputValue(input[0]),
                        inputName = input.attr('name');

                    if (inputName) {
                        if (/\[]$/.test(inputName)) {
                            inputName = inputName.replace(/\[]$/, '');
                            if (!(formData[inputName] instanceof Array)) {
                                formData[inputName] = [];
                            }
                            formData[inputName].push(value)
                        } else {
                            formData[inputName] = value;
                        }
                    }

                    if (!!input.attr(_data.validation) || !!input.attr(_data.regex)) {
                        if (!validateInput(input[0], value)) {
                            isValid = false;
                        }
                    }
                }
            );

            prepareFormData();

            return isValid;

        }
364033
private function getQuestion($question, $default = null, callable $validator = null, array $values = null)
    {
        $question = new Question(
            sprintf('<info>%s</info>%s: ', $question, $default ? sprintf(' [<comment>%s</comment>]', $default) : ''),
            $default
        );

        $question
            ->setValidator($validator)
            ->setAutocompleterValues($values);

        return $question;
    }
868438
function isIOSMessageValid(message){

    if(!(message instanceof IOSMessage)){
        throw new Error('message is invalid');
    }

    if(parseInt(message.expireTime) !== message.expireTime || message.expireTime < 0 || message.expireTime > 60*60*24*3){
        throw new Error('expireTime is invalid');
    }

    if(parseInt(message.sendTime) !== message.sendTime || message.sendTime < 0){
        throw new Error('sendTime is invalid');
    }

    if(!isIOSCustomContentValid(message.customContent)){
        throw new Error('customContent is invalid');
    }

    if(!isAccessTimeValid(message.acceptTime)){
        throw new Error('acceptTime is invalid');
    }

    if(typeof message.alert !== 'string' && typeof message.alert !== 'object'){
        throw new Error('alert is invalid');
    }

    if((message.badge !== null) && (parseInt(message.badge) !== message.badge)){
        throw new Error('badge is invalid');
    }

    if((message.sound !== null ) && (typeof message.sound !== 'string')){
        throw new Error('sound is invalid');
    }

    if(message.loopTimes !== null && parseInt(message.loopTimes) != message.loopTimes){
        throw new Error('loopTimes is invalid');
    }

    if(message.loopInterval !== null && parseInt(message.loopInterval) != message.loopInterval){
        throw new Error('loopInterval is invalid');
    }

    return true;
}
1043908
function ask(questions, finish, answers, input, output) {
    finish = finish || function() {};
    input = input || function(cb) {process.stdin.on('data', cb);};
    output = output || function(a) {console.log(a);};

    var i = 0;
    var ret = {};
    var e = questions[0];
    var v = match(ops, e);

    output(getOutput(e, v));
    input(getInput);

    function getOutput(e, v) {
        var o = f.isFunction(v.output)? v.output(e): '';

        return e.q + o;
    }

    function getInput(t) {
        t = t.trim();
        var r = v.exec(t, e);

        if(f.isDefined(r)) {
            ret[e.id] = r;
            i++;

            if(i >= questions.length) {
                // XXX: separate this somehow
                process.stdin.removeListener('data', getInput);
                process.stdin.pause();

                finish(ret);
            }
            else {
                e = questions[i];
                v = match(ops, e);
                output(getOutput(e, v));
            }
        }
    }
}
566235
def ask(question):
    '''
    
    '''
    while True:
        ans = input(question)
        al = ans.lower()
        if match('^y(es)?$', al):
            return True
        elif match('^n(o)?$', al):
            return False
        elif match('^q(uit)?$', al):
            stdout.write(CYAN)
            print("\nGoodbye.\n")
            stdout.write(RESET)
            quit()
        else:
            stdout.write(RED)
            print("%s is invalid. Enter (y)es, (n)o or (q)uit." % ans)
            stdout.write(RESET)
890649
private static String formatString(String message, Object[] values) {
        if (Checker.isNotEmpty(message)) {
            if (Checker.isNotEmpty(values)) {
                return StrUtil.format(String.format(message, values), values);
            }
            return message;
        }
        return ValueConsts.EMPTY_STRING;
    }
727267
function validate(values) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    var s = this;

    var _tv4$validateMultiple = tv4.validateMultiple(values, s),
        valid = _tv4$validateMultiple.valid,
        errors = _tv4$validateMultiple.errors;

    if (valid) {
      return null;
    }

    var assign = options.assign,
        _options$name = options.name,
        name = _options$name === void 0 ? 'SchemaError' : _options$name;
    var _s$schema = s.schema,
        schema = _s$schema === void 0 ? {} : _s$schema;
    var error = new Error("Validation failed with schema: ".concat(schema.title || schema.id || schema.description));
    return Object.assign(error, {
      id: uuid.v4(),
      name: name,
      errors: errors,
      schema: schema,
      values: values,
      engine: 'tv4'
    }, assign);
  }
379958
async function requestInput(message, suggestions = []) {
  const answerName = 'requestInput';
  const answers = await inquirer.prompt([
    {
      message,
      suggestions,
      name: answerName,
      type: suggestions.length ? 'suggest' : 'input',
    },
  ]);
  return answers[answerName];
}
218522
function validate(message, type) {
  assert(
    typeOf(message) === 'object',
    'You must pass a message object.',
  );

  rules.forEach((rule) => {
    if (message[rule.name]) {
      const types = [].concat(rule.types);

      assert(
        types.some(t => typeOf(message[rule.name]) === t),
        `"${rule.name}" must be ${types.join(' or ')}.`,
      );
    }
  });

  if (asserts[type]) {
    asserts[type](message);
  } else {
    throw new TypeError('Invalid event type');
  }
}