Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StrictConfirmationQuestion.php

function StrictConfirmationQuestion::getDefaultValidator

Returns the default answer validator.

1 call to StrictConfirmationQuestion::getDefaultValidator()
StrictConfirmationQuestion::__construct in vendor/composer/composer/src/Composer/Question/StrictConfirmationQuestion.php
Constructor.s

File

vendor/composer/composer/src/Composer/Question/StrictConfirmationQuestion.php, line 83

Class

StrictConfirmationQuestion
Represents a yes/no question Enforces strict responses rather than non-standard answers counting as default Based on Symfony\Component\Console\Question\ConfirmationQuestion

Namespace

Composer\Question

Code

private function getDefaultValidator() : callable {
    return static function ($answer) : bool {
        if (!is_bool($answer)) {
            throw new InvalidArgumentException('Please answer yes, y, no, or n.');
        }
        return $answer;
    };
}
RSS feed
Powered by Drupal