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

Breadcrumb

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

function IOInterface::askAndValidate

Asks for a value and validates the response.

The validator receives the data to validate. It must return the validated data when the data is valid and throw an exception otherwise.

Parameters

string $question The question to ask:

callable $validator A PHP callback:

null|int $attempts Max number of times to ask before giving up (default of null means infinite):

mixed $default The default answer if none is given by the user:

Return value

mixed

Throws

\Exception When any of the validators return an error

2 methods override IOInterface::askAndValidate()
ConsoleIO::askAndValidate in vendor/composer/composer/src/Composer/IO/ConsoleIO.php
@inheritDoc
NullIO::askAndValidate in vendor/composer/composer/src/Composer/IO/NullIO.php
@inheritDoc

File

vendor/composer/composer/src/Composer/IO/IOInterface.php, line 172

Class

IOInterface
The Input/Output helper interface.

Namespace

Composer\IO

Code

public function askAndValidate(string $question, callable $validator, ?int $attempts = null, $default = null);

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal