Type alias QuestionOptions<FormattedValue>

QuestionOptions<FormattedValue>: {
    format?: Unary<string, FormattedValue>;
    query: string;
    retry?: boolean;
    validate?: Unary<FormattedValue, Maybe<string>>;
}

Options object for the question function.

Type Parameters

  • FormattedValue = string

Type declaration

  • Optional Readonly format?: Unary<string, FormattedValue>

    Function to format the question's answer given by the user.

    Example

    {
    format: value => parseInt(value, 18),
    }

    Param

    The question's answer given by the user.

    Returns

    Formatted value.

  • Readonly query: string

    Query to show to the user.

  • Optional Readonly retry?: boolean

    Whether to retry the question if the answer is invalid.

  • Optional Readonly validate?: Unary<FormattedValue, Maybe<string>>

    Function to validate the question's answer given by the user (after formatting). Returning an string will be used to reject with an error, while an empty string or undefined is considered valid.

    Example

    {
    validate: value => value % 2 === 0,
    }

    Param

    The question's answer given by the user.

    Returns

    Either an error, an empty string or undefined.