@@ -6,15 +6,14 @@ This example demonstrates various use cases of the Flask-InputFilter package, sh
66
77```
88example 1/
9- ├── app.py # Main Flask application
10- ├── filters/ # InputFilter classes
11- │ ├── __init__.py # Package exports
12- │ ├── user_filter.py # User input validation
13- │ ├── address_filter.py # Address input validation
14- │ ├── profile_filter.py # Profile input validation
15- │ └── product_filter.py # Product input validation
16- ├── test.http # HTTP test requests
17- └── README.md # This file
9+ ├── app.py # Main Flask application
10+ ├── filters/ # InputFilter classes
11+ │ ├── __init__.py # Package exports
12+ │ ├── product_inputfilter.py # Product input validation
13+ │ ├── profile_inputfilter.py # Profile input validation
14+ │ └── user_inputfilter.py # User input validation
15+ ├── test.http # HTTP test requests
16+ └── README.md # This file
1817```
1918
2019## Features Demonstrated
@@ -29,12 +28,12 @@ example 1/
2928
30291 . Make sure you have Flask and Flask-InputFilter installed:
3130``` bash
32- pip install flask flask-inputfilter
31+ pip install flask flask-inputfilter
3332```
3433
35342 . Run the example application:
3635``` bash
37- python app.py
36+ python app.py
3837```
3938
4039The server will start on ` http://localhost:5000 ` .
@@ -55,18 +54,19 @@ You can use the provided `test.http` file to test the endpoints. This file conta
5554 - Demonstrates nested filtering with multiple InputFilter classes
5655 - Optional phone number field
5756
58- 3 . ` POST /api/products `
57+ 3 . ` POST /api/product `
5958 - Creates a new product
60- - Demonstrates basic type conversion with ToFloatFilter
61- - Optional tags field
59+ - Demonstrates list validation for tags
60+ - Required fields: name, price
61+ - Optional tags field as a list of strings
6262
6363## Example Requests
6464
6565### Successful User Creation
6666``` json
6767{
6868 "name" : " John Doe" ,
69- "age" : " 30 " ,
69+ "age" : 30 ,
70707171}
7272```
@@ -76,13 +76,13 @@ You can use the provided `test.http` file to test the endpoints. This file conta
7676{
7777 "user" : {
7878 "name" : " John Doe" ,
79- "age" : " 30 " ,
79+ "age" : 30 ,
80808181 },
8282 "address" : {
8383 "street" : " 123 Main St" ,
8484 "city" : " New York" ,
85- "zip_code" : " 10001"
85+ "zip_code" : 10001
8686 },
8787 "phone" : " +1234567890"
8888}
@@ -92,8 +92,11 @@ You can use the provided `test.http` file to test the endpoints. This file conta
9292``` json
9393{
9494 "name" : " Laptop" ,
95- "price" : " 999.99" ,
96- "tags" : " electronics,computers,gadgets"
95+ "price" : 999 ,
96+ "tags" : [
97+ " electronics" ,
98+ " sports"
99+ ]
97100}
98101```
99102
@@ -138,9 +141,9 @@ You can use the provided `test.http` file to test the endpoints. This file conta
138141The application demonstrates various validation errors:
139142- Missing required fields
140143- Invalid email format
141- - Invalid zip code format
142- - Invalid phone number format
143- - Negative price values
144- - Invalid data types
144+ - Invalid age format (must be integer)
145+ - Invalid price format
146+ - Invalid tags format (must be a list of strings)
147+ - Invalid nested data structures
145148
146149Each error will return a 400 status code with a descriptive error message.
0 commit comments