# inp_kwargs
**Easily validate user inputs with Python, no hassle required!**
A Python library for easy input validation using kwargs. This library helps to easily validate inputs such as integers, strings, and more, without needing to write complex validation logic.
## Example
### Validating an Integer Input
```python
from inp_kwargs import input_int
# Request a number between 1 and 100
number = input_int("Enter a number between 1 and 100: ",
error_txt="Error: You have to input an integer.",
min_value=1,
error_min="Error: The number must be greater than or equal to 1.",
max_value=100,
error_max="Error: The number must be less than or equal to 100.")
print(f"You entered: {number}")
# Request a number between 1 and 100 without custom error messages
number = input_int("Enter a number: ", min_value=1, max_value=100)
print(f"You entered: {number}")
```
# `input_int` Function Validations
The `input_int` function supports the following validation options:
### 1. **Minimum Value** (`min_value`)
- Ensures the input is greater than or equal to the specified minimum value.
- **Usage**: `min_value=10`
### 2. **Maximum Value** (`max_value`)
- Ensures the input is less than or equal to the specified maximum value.
- **Usage**: `max_value=100`
### 3. **Range** (`range`)
- Ensures the input is in the specified range of values.
- **Usage**: `range=[10, 20, 30]`
### 4. **Allowed Values** (`allowed_values`)
- Ensures the input matches one of the allowed values.
- **Usage**: `allowed_values=[5, 10, 15]`
### 5. **Even Number** (`even`)
- Ensures the input is an even number.
- **Usage**: `even=True`
### 6. **Odd Number** (`odd`)
- Ensures the input is an odd number.
- **Usage**: `odd=True`
### 7. **Multiple of** (`multiple_of`)
- Ensures the input is a multiple of a specified number.
- **Usage**: `multiple_of=5`
### 8. **Type Error Message** (`type_error_message`)
- Customizes the error message when the input is not a valid integer.
- **Usage**: `type_error_message="Invalid input!"`
## Features
- Validate integer inputs with custom error messages.
- Set minimum and maximum value constraints.
- Simple and reusable functions for input validation.
## Installation
You can install inp_kwargs directly from PyPI:
```bash
pip install inp_kwargs
```
## License
MIT License. See the LICENSE file for more details.
Raw data
{
"_id": null,
"home_page": "https://github.com/TheCatAvila/inp_kwargs.git",
"name": "inp-kwargs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "input validation, kwargs, python",
"author": "Diego \u00c1vila",
"author_email": "thecatavila@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/50/da/5341d9bfab3b2b13826d3cf8eed4e74f9e1e8b96767770f639579a168f45/inp_kwargs-0.1.1.tar.gz",
"platform": null,
"description": "# inp_kwargs\r\n**Easily validate user inputs with Python, no hassle required!**\r\n\r\nA Python library for easy input validation using kwargs. This library helps to easily validate inputs such as integers, strings, and more, without needing to write complex validation logic.\r\n\r\n## Example\r\n\r\n### Validating an Integer Input\r\n\r\n```python\r\nfrom inp_kwargs import input_int\r\n\r\n# Request a number between 1 and 100\r\nnumber = input_int(\"Enter a number between 1 and 100: \", \r\n error_txt=\"Error: You have to input an integer.\",\r\n min_value=1, \r\n error_min=\"Error: The number must be greater than or equal to 1.\",\r\n max_value=100, \r\n error_max=\"Error: The number must be less than or equal to 100.\")\r\n\r\nprint(f\"You entered: {number}\")\r\n\r\n# Request a number between 1 and 100 without custom error messages\r\nnumber = input_int(\"Enter a number: \", min_value=1, max_value=100)\r\nprint(f\"You entered: {number}\")\r\n\r\n```\r\n\r\n# `input_int` Function Validations\r\n\r\nThe `input_int` function supports the following validation options:\r\n\r\n### 1. **Minimum Value** (`min_value`)\r\n - Ensures the input is greater than or equal to the specified minimum value.\r\n - **Usage**: `min_value=10`\r\n\r\n### 2. **Maximum Value** (`max_value`)\r\n - Ensures the input is less than or equal to the specified maximum value.\r\n - **Usage**: `max_value=100`\r\n\r\n### 3. **Range** (`range`)\r\n - Ensures the input is in the specified range of values.\r\n - **Usage**: `range=[10, 20, 30]`\r\n\r\n### 4. **Allowed Values** (`allowed_values`)\r\n - Ensures the input matches one of the allowed values.\r\n - **Usage**: `allowed_values=[5, 10, 15]`\r\n\r\n### 5. **Even Number** (`even`)\r\n - Ensures the input is an even number.\r\n - **Usage**: `even=True`\r\n\r\n### 6. **Odd Number** (`odd`)\r\n - Ensures the input is an odd number.\r\n - **Usage**: `odd=True`\r\n\r\n### 7. **Multiple of** (`multiple_of`)\r\n - Ensures the input is a multiple of a specified number.\r\n - **Usage**: `multiple_of=5`\r\n\r\n### 8. **Type Error Message** (`type_error_message`)\r\n - Customizes the error message when the input is not a valid integer.\r\n - **Usage**: `type_error_message=\"Invalid input!\"`\r\n\r\n## Features\r\n- Validate integer inputs with custom error messages.\r\n- Set minimum and maximum value constraints.\r\n- Simple and reusable functions for input validation.\r\n\r\n\r\n## Installation\r\nYou can install inp_kwargs directly from PyPI:\r\n```bash\r\npip install inp_kwargs\r\n```\r\n\r\n## License\r\nMIT License. See the LICENSE file for more details.\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A library for easy input validation with kwargs",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/TheCatAvila/inp_kwargs.git"
},
"split_keywords": [
"input validation",
" kwargs",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "270952c21b09c46b6270c96792ae2de7b259f42b378d4b7a1c57959e0a2501fa",
"md5": "ae65f2e326fa8569080e46784a18a3a8",
"sha256": "e32e580326b45a19e3dfa1d920865c1262eaf073297aca1d230770bb06aa59dc"
},
"downloads": -1,
"filename": "inp_kwargs-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ae65f2e326fa8569080e46784a18a3a8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3848,
"upload_time": "2025-01-04T00:06:14",
"upload_time_iso_8601": "2025-01-04T00:06:14.347229Z",
"url": "https://files.pythonhosted.org/packages/27/09/52c21b09c46b6270c96792ae2de7b259f42b378d4b7a1c57959e0a2501fa/inp_kwargs-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "50da5341d9bfab3b2b13826d3cf8eed4e74f9e1e8b96767770f639579a168f45",
"md5": "6fae6f2f1ab9ce3f9d42ab1004257e78",
"sha256": "c533f7023e2347c0fc1b73ae1120489fe6980ae75e2a592efdf5456bcb1b4764"
},
"downloads": -1,
"filename": "inp_kwargs-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "6fae6f2f1ab9ce3f9d42ab1004257e78",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3536,
"upload_time": "2025-01-04T00:06:15",
"upload_time_iso_8601": "2025-01-04T00:06:15.875500Z",
"url": "https://files.pythonhosted.org/packages/50/da/5341d9bfab3b2b13826d3cf8eed4e74f9e1e8b96767770f639579a168f45/inp_kwargs-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-04 00:06:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TheCatAvila",
"github_project": "inp_kwargs",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "inp-kwargs"
}