Skip to content

Commit 3f50227

Browse files
committed
Update README with blank_none information
1 parent cb5221f commit 3f50227

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

README.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,27 @@ These can be used in tandem to describe a parameter to validate: `parameter_name
142142
### Validation with arguments to Parameter
143143
Validation beyond type-checking can be done by passing arguments into the constructor of the `Parameter` subclass. The arguments available for use on each type hint are:
144144

145-
| Parameter Name | Type of Argument | Effective On Types | Description |
146-
|-------------------|--------------------------------------------------|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
147-
| `default` | any | All, except in `Route` | Specifies the default value for the field, makes non-Optional fields not required |
148-
| `min_str_length` | `int` | `str` | Specifies the minimum character length for a string input |
149-
| `max_str_length` | `int` | `str` | Specifies the maximum character length for a string input |
150-
| `min_list_length` | `int` | `list` | Specifies the minimum number of elements in a list |
151-
| `max_list_length` | `int` | `list` | Specifies the maximum number of elements in a list |
152-
| `min_int` | `int` | `int` | Specifies the minimum number for an integer input |
153-
| `max_int` | `int` | `int` | Specifies the maximum number for an integer input |
154-
| `whitelist` | `str` | `str` | A string containing allowed characters for the value |
155-
| `blacklist` | `str` | `str` | A string containing forbidden characters for the value |
156-
| `pattern` | `str` | `str` | A regex pattern to test for string matches |
157-
| `func` | `Callable[Any] -> Union[bool, tuple[bool, str]]` | All | A function containing a fully customized logic to validate the value. See the [custom validation function](#custom-validation-function) below for usage |
158-
| `datetime_format` | `str` | `datetime.datetime` | Python datetime format string datetime format string ([datetime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes)) |
159-
| `comment` | `str` | All | A string to display as the argument description in any generated documentation |
160-
| `alias` | `str` | All but `FileStorage` | An expected parameter name to receive instead of the function name. |
161-
| `json_schema` | `dict` | `dict` | An expected [JSON Schema](https://json-schema.org) which the dict input must conform to |
162-
| `content_types` | `list[str]` | `FileStorage` | Allowed `Content-Type`s |
163-
| `min_length` | `int` | `FileStorage` | Minimum `Content-Length` for a file |
164-
| `max_length` | `int` | `FileStorage` | Maximum `Content-Length` for a file |
145+
| Parameter Name | Type of Argument | Effective On Types | Description |
146+
|-------------------|--------------------------------------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
147+
| `default` | any | All, except in `Route` | Specifies the default value for the field, makes non-Optional fields not required |
148+
| `min_str_length` | `int` | `str` | Specifies the minimum character length for a string input |
149+
| `max_str_length` | `int` | `str` | Specifies the maximum character length for a string input |
150+
| `min_list_length` | `int` | `list` | Specifies the minimum number of elements in a list |
151+
| `max_list_length` | `int` | `list` | Specifies the maximum number of elements in a list |
152+
| `min_int` | `int` | `int` | Specifies the minimum number for an integer input |
153+
| `max_int` | `int` | `int` | Specifies the maximum number for an integer input |
154+
| `whitelist` | `str` | `str` | A string containing allowed characters for the value |
155+
| `blacklist` | `str` | `str` | A string containing forbidden characters for the value |
156+
| `pattern` | `str` | `str` | A regex pattern to test for string matches |
157+
| `func` | `Callable[Any] -> Union[bool, tuple[bool, str]]` | All | A function containing a fully customized logic to validate the value. See the [custom validation function](#custom-validation-function) below for usage |
158+
| `datetime_format` | `str` | `datetime.datetime` | Python datetime format string datetime format string ([datetime format codes](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes)) |
159+
| `comment` | `str` | All | A string to display as the argument description in any generated documentation |
160+
| `alias` | `str` | All but `FileStorage` | An expected parameter name to receive instead of the function name. |
161+
| `json_schema` | `dict` | `dict` | An expected [JSON Schema](https://json-schema.org) which the dict input must conform to |
162+
| `content_types` | `list[str]` | `FileStorage` | Allowed `Content-Type`s |
163+
| `min_length` | `int` | `FileStorage` | Minimum `Content-Length` for a file |
164+
| `max_length` | `int` | `FileStorage` | Maximum `Content-Length` for a file |
165+
| `blank_none` | `bool` | `Optional[str]` | If `True`, an empty string will be converted to `None`, defaults to configured `FPV_BLANK_NONE`, see [Validation Behavior Configuration](#validation-behavior-configuration) for more |
165166

166167
These validators are passed into the `Parameter` subclass in the route function, such as:
167168
* `username: str = Json(default="defaultusername", min_length=5)`
@@ -183,18 +184,25 @@ def is_odd(val: int):
183184
return val % 2 != 0, "val must be odd"
184185
```
185186

186-
### API Documentation
187-
Using the data provided through parameters, docstrings, and Flask route registrations, Flask Parameter Validation can generate API Documentation in various formats.
188-
To make this easy to use, it comes with a `Blueprint` and the output and configuration options below:
187+
### Configuration Options
189188

190-
#### Format
189+
#### API Documentation Configuration
191190
* `FPV_DOCS_SITE_NAME: str`: Your site's name, to be displayed in the page title, default: `Site`
192191
* `FPV_DOCS_CUSTOM_BLOCKS: array`: An array of dicts to display as cards at the top of your documentation, with the (optional) keys:
193192
* `title: Optional[str]`: The title of the card
194193
* `body: Optional[str] (HTML allowed)`: The body of the card
195194
* `order: int`: The order in which to display this card (out of the other custom cards)
196195
* `FPV_DOCS_DEFAULT_THEME: str`: The default theme to display in the generated webpage
197196

197+
See the [API Documentation](#api-documentation) below for other information on API Documentation generation
198+
199+
#### Validation Behavior Configuration
200+
* `FPV_BLANK_NONE: bool`: Globally override the default `blank_none` behavior for routes in your application, defaults to `False` if unset
201+
202+
### API Documentation
203+
Using the data provided through parameters, docstrings, and Flask route registrations, Flask Parameter Validation can generate API Documentation in various formats.
204+
To make this easy to use, it comes with a `Blueprint` and the output shown below and configuration options [above](#api-documentation-configuration):
205+
198206
#### Included Blueprint
199207
The documentation blueprint can be added using the following code:
200208
```py

0 commit comments

Comments
 (0)