|
6 | 6 | import logging |
7 | 7 | import sys |
8 | 8 | from typing import TYPE_CHECKING, Any, Optional, Type, TypeVar, Union |
| 9 | +import warnings |
9 | 10 |
|
10 | 11 | from flask import Response, g, request |
11 | 12 |
|
@@ -211,6 +212,13 @@ def add_condition(self, condition: BaseCondition) -> None: |
211 | 212 | Args: |
212 | 213 | condition (BaseCondition): The condition to add. |
213 | 214 | """ |
| 215 | + warnings.warn( |
| 216 | + "Using 'add_condition' is deprecated, use 'condition()' " |
| 217 | + "instead. https://leandercs.github.io/flask-inputfilter" |
| 218 | + "/options/declarative_api.html", |
| 219 | + DeprecationWarning, |
| 220 | + stacklevel=2, |
| 221 | + ) |
214 | 222 | self.conditions.append(condition) |
215 | 223 |
|
216 | 224 | def _register_decorator_components(self) -> None: |
@@ -497,6 +505,13 @@ def add( |
497 | 505 | copy (Optional[str]): The name of the field to copy the value |
498 | 506 | from. |
499 | 507 | """ |
| 508 | + warnings.warn( |
| 509 | + "Using 'add' is deprecated, use 'field()' " |
| 510 | + "instead. https://leandercs.github.io/flask-inputfilter" |
| 511 | + "/options/declarative_api.html", |
| 512 | + DeprecationWarning, |
| 513 | + stacklevel=2, |
| 514 | + ) |
500 | 515 | if name in self.fields: |
501 | 516 | raise ValueError(f"Field '{name}' already exists.") |
502 | 517 |
|
@@ -643,6 +658,13 @@ def add_global_filter(self, filter: BaseFilter) -> None: |
643 | 658 | Args: |
644 | 659 | filter: The filter to add. |
645 | 660 | """ |
| 661 | + warnings.warn( |
| 662 | + "Using 'add_global_filter' is deprecated, use 'global_filter()' " |
| 663 | + "instead. https://leandercs.github.io/flask-inputfilter" |
| 664 | + "/options/declarative_api.html", |
| 665 | + DeprecationWarning, |
| 666 | + stacklevel=2, |
| 667 | + ) |
646 | 668 | self.global_filters.append(filter) |
647 | 669 |
|
648 | 670 | def get_global_filters(self) -> list[BaseFilter]: |
@@ -745,6 +767,13 @@ def add_global_validator(self, validator: BaseValidator) -> None: |
745 | 767 | Args: |
746 | 768 | validator (BaseValidator): The validator to add. |
747 | 769 | """ |
| 770 | + warnings.warn( |
| 771 | + "Using 'add_global_validator' is deprecated, use 'global_validator()' " |
| 772 | + "instead. https://leandercs.github.io/flask-inputfilter" |
| 773 | + "/options/declarative_api.html", |
| 774 | + DeprecationWarning, |
| 775 | + stacklevel=2, |
| 776 | + ) |
748 | 777 | self.global_validators.append(validator) |
749 | 778 |
|
750 | 779 | def get_global_validators(self) -> list[BaseValidator]: |
|
0 commit comments