> For the complete documentation index, see [llms.txt](https://cyr1en.gitbook.io/commandprompter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cyr1en.gitbook.io/commandprompter/features/input-validation.md).

# Input Validation

Input validation restricts prompt inputs using regular expressions, online player checks, or JavaScript expressions.

To use input validation:

1. Define a validator in `prompt-config.yml` under `Input-Validation`.
2. Apply it using the `-iv:<alias>` prompt flag.

***

## Validator Types

| Validator Type    | Config Key      | Description                                                  |
| ----------------- | --------------- | ------------------------------------------------------------ |
| **Regex**         | `Regex`         | Validates if the input matches a regular expression pattern. |
| **Online Player** | `Online-Player` | Validates if the input matches the name of an online player. |
| **JS Expression** | `JS-Expression` | Validates by evaluating a JavaScript expression.             |

***

## Configuration Example (`prompt-config.yml`)

```yaml
Input-Validation:
  Integer-Sample:
    Alias: is
    Regex: '^\d+'
    Err-Message: '&cPlease enter a valid integer!'
  Alpha-Sample:
    Alias: ss
    Regex: '[A-Za-z ]+'
    Err-Message: '&cInput must only consist of letters!'
  Online-Validator:
    Alias: ov
    Online-Player: true
    Err-Message: '&cThat player is not online!'
```

***

## Usage

Apply the validator to a prompt using `-iv:<alias>`:

```
/command <Enter integer -iv:is> <Enter letters -iv:ss> <Enter online player -iv:ov>
```

If validation fails, the `Err-Message` is sent to the player, and the prompt is re-displayed.

*Useful Resource: Learn more about* [*Regular Expressions*](https://github.com/Varunram/Awesome-Regex-Resources)*.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cyr1en.gitbook.io/commandprompter/features/input-validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
