Metadata-Version: 2.4
Name: bear-django-request-normalizer
Version: 0.3.0
Summary: A Django middleware to clean and normalize incoming request data (GET, POST, JSON).
Author-email: Bohdan Riabunets <bearablyk@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/bearablyk/django-request-normalizer
Project-URL: Issues, https://github.com/bearablyk/django-request-normalizer/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Framework :: Django
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: Django>=3.2
Requires-Dist: bear-django-request-utils>=0.1.0

# Django Request Normalizer

A configurable Django middleware that automatically cleans and normalizes incoming request data before it reaches your views.

## Features

-   **Trims Whitespace:** Strips leading/trailing whitespace from all string values.
-   **Normalizes Booleans:** Converts string values like `"true"` and `"false"` to actual booleans.
-   **Normalizes Nulls:** Converts string `"null"`, empty strings `""` for ID fields, and integer `0` for ID fields to `None`.
-   **Cleans Email:** Removes spaces and lowercases email fields.
-   **Handles All Data:** Works seamlessly with `GET` parameters, `application/json`, `multipart/form-data`, and `x-www-form-urlencoded` data.
-   **Configurable:** You can enable/disable the middleware or specify which URL prefixes it should act on.

## Installation

```bash
pip install django-request-normalizer
```

## Usage

1.  Add the middleware to your `MIDDLEWARE` list in `settings.py`. It should be placed before any middleware that accesses request data, such as DRF's authentication classes or your own views.

```python
# settings.py
MIDDLEWARE = [
    # ...
    'request_normalizer.middleware.RequestNormalizerMiddleware',
    # ...
]
```
