Let's take this application as example:
```Python hl_lines="7"
-{!./tutorial/src/query-params-schema/tutorial001.py!}
+{!./tutorial/src/query-params-str-validations/tutorial001.py!}
```
The query parameter `q` is of type `str`, and by default is `None`, so it is optional.
To achieve that, first import `Query` from `fastapi`:
```Python hl_lines="1"
-{!./tutorial/src/query-params-schema/tutorial002.py!}
+{!./tutorial/src/query-params-str-validations/tutorial002.py!}
```
## Use `Query` as the default value
And now use it as the default value of your parameter, setting the parameter `max_length` to 50:
```Python hl_lines="7"
-{!./tutorial/src/query-params-schema/tutorial002.py!}
+{!./tutorial/src/query-params-str-validations/tutorial002.py!}
```
As we have to replace the default value `None` with `Query(None)`, the first parameter to `Query` serves the same purpose of defining that default value.
You can also add a parameter `min_length`:
```Python hl_lines="7"
-{!./tutorial/src/query-params-schema/tutorial003.py!}
+{!./tutorial/src/query-params-str-validations/tutorial003.py!}
```
## Add regular expressions
You can define a <abbr title="A regular expression, regex or regexp is a sequence of characters that define a search pattern for strings.">regular expression</abbr> that the parameter should match:
```Python hl_lines="8"
-{!./tutorial/src/query-params-schema/tutorial004.py!}
+{!./tutorial/src/query-params-str-validations/tutorial004.py!}
```
This specific regular expression checks that the received parameter value:
Let's say that you want to declare the `q` query parameter to have a `min_length` of `3`, and to have a default value of `"fixedquery"`:
```Python hl_lines="7"
-{!./tutorial/src/query-params-schema/tutorial005.py!}
+{!./tutorial/src/query-params-str-validations/tutorial005.py!}
```
!!! note
So, when you need to declare a value as required while using `Query`, you can use `...` as the first argument:
```Python hl_lines="7"
-{!./tutorial/src/query-params-schema/tutorial006.py!}
+{!./tutorial/src/query-params-str-validations/tutorial006.py!}
```
!!! info
You can add a `title`:
```Python hl_lines="7"
-{!./tutorial/src/query-params-schema/tutorial007.py!}
+{!./tutorial/src/query-params-str-validations/tutorial007.py!}
```
And a `description`:
```Python hl_lines="11"
-{!./tutorial/src/query-params-schema/tutorial008.py!}
+{!./tutorial/src/query-params-str-validations/tutorial008.py!}
```
## Alias parameters
Then you can declare an `alias`, and that alias is what will be used to find the parameter value:
```Python hl_lines="7"
-{!./tutorial/src/query-params-schema/tutorial009.py!}
+{!./tutorial/src/query-params-str-validations/tutorial009.py!}
```
## Deprecating parameters
Then pass the parameter `deprecated=True` to `Query`:
```Python hl_lines="16"
-{!./tutorial/src/query-params-schema/tutorial010.py!}
+{!./tutorial/src/query-params-str-validations/tutorial010.py!}
```
The docs will show it like this:
-<img src="/img/tutorial/query-params-schema/image01.png">
+<img src="/img/tutorial/query-params-str-validations/image01.png">