Skip to content

Commit db2ffca

Browse files
committed
feat(@inquirer/input): Document pattern/patternError in README
1 parent 160958a commit db2ffca

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/input/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ const answer = await input({ message: 'Enter your name' });
6060

6161
## Options
6262

63-
| Property | Type | Required | Description |
64-
| ----------- | ----------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
65-
| message | `string` | yes | The question to ask |
66-
| default | `string` | no | Default value if no answer is provided; see the prefill option below for governing it's behaviour. |
67-
| prefill | `'tab' \| 'editable'` | no | Defaults to `'tab'`. If set to `'tab'`, pressing `backspace` will clear the default and pressing `tab` will inline the value for edits; If set to `'editable'`, the default value will already be inlined to edit. |
68-
| required | `boolean` | no | Defaults to `false`. If set to true, `undefined` (empty) will not be accepted for this. |
69-
| transformer | `(string, { isFinal: boolean }) => string` | no | Transform/Format the raw value entered by the user. Once the prompt is completed, `isFinal` will be `true`. This function is purely visual, modify the answer in your code if needed. |
70-
| validate | `string => boolean \| string \| Promise<boolean \| string>` | no | On submit, validate the filtered answered content. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. |
71-
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
63+
| Property | Type | Required | Description |
64+
| ------------ | ----------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
65+
| message | `string` | yes | The question to ask |
66+
| default | `string` | no | Default value if no answer is provided; see the prefill option below for governing it's behaviour. |
67+
| prefill | `'tab' \| 'editable'` | no | Defaults to `'tab'`. If set to `'tab'`, pressing `backspace` will clear the default and pressing `tab` will inline the value for edits; If set to `'editable'`, the default value will already be inlined to edit. |
68+
| required | `boolean` | no | Defaults to `false`. If set to true, `undefined` (empty) will not be accepted for this. |
69+
| transformer | `(string, { isFinal: boolean }) => string` | no | Transform/Format the raw value entered by the user. Once the prompt is completed, `isFinal` will be `true`. This function is purely visual, modify the answer in your code if needed. |
70+
| validate | `string => boolean \| string \| Promise<boolean \| string>` | no | On submit, validate the filtered answered content. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash. |
71+
| pattern | `RegExp` | no | Regular expression to validate the input against. If the input doesn't match the pattern, validation will fail with the error message specified in `patternError`. |
72+
| patternError | `string` | no | Error message to display when the input doesn't match the `pattern`. Defaults to `'Invalid input'`. |
73+
| theme | [See Theming](#Theming) | no | Customize look of the prompt. |
7274

7375
## Theming
7476

0 commit comments

Comments
 (0)