Skip to content

Commit 763e5c3

Browse files
committed
29 | Remove IsMimeTypeValidator
1 parent 39d19c1 commit 763e5c3

File tree

7 files changed

+3
-86
lines changed

7 files changed

+3
-86
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ If the data is invalid, a 400 response with an error message will be returned.
123123
# Do something with validated data
124124
id = data.get('id')
125125
zipcode = data.get('zipcode')
126-
126+
city = data.get('city')
127127
128128
129129
See also

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,4 @@ If the data is invalid, a 400 response with an error message will be returned.
119119
# Do something with validated data
120120
id = data.get('id')
121121
zipcode = data.get('zipcode')
122+
city = data.get('city')

docs/options/validator.rst

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ The following validators are available:
6666
- `IsJsonValidator`_
6767
- `IsLowercaseValidator`_
6868
- `IsMacAddressValidator`_
69-
- `IsMimeTypeValidator`_
7069
- `IsPastDateValidator`_
7170
- `IsPortValidator`_
7271
- `IsRgbColorValidator`_
@@ -827,36 +826,6 @@ Ensures the input is a string and matches a regular expression pattern for MAC a
827826
IsMacAddressValidator()
828827
])
829828
830-
831-
IsMimeTypeValidator
832-
~~~~~~~~~~~~~~~~~~~
833-
834-
**Description:**
835-
836-
Checks if a value is a valid MIME type. The validator uses a regular expression to verify that the input string follows the typical pattern for MIME types (e.g., "text/html").
837-
838-
**Parameters:**
839-
840-
- **error_message** (*Optional[str]*): Custom error message if the value is not a valid MIME type.
841-
842-
**Expected Behavior:**
843-
844-
Confirms that the input is a string and that it matches the MIME type pattern. Raises a ``ValidationError`` if the value does not match the expected format.
845-
846-
**Example Usage:**
847-
848-
.. code-block:: python
849-
850-
from flask_inputfilter import InputFilter
851-
from flask_inputfilter.Validator import IsMimeTypeValidator
852-
853-
class FileInputFilter(InputFilter):
854-
def __init__(self):
855-
super().__init__()
856-
self.add('mime_type', validators=[
857-
IsMimeTypeValidator()
858-
])
859-
860829
IsPastDateValidator
861830
~~~~~~~~~~~~~~~~~~~
862831
**Description:**

flask_inputfilter/Validator/IsMimeTypeValidator.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

flask_inputfilter/Validator/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from .IsJsonValidator import IsJsonValidator
2828
from .IsLowercaseValidator import IsLowercaseValidator
2929
from .IsMacAddressValidator import IsMacAddressValidator
30-
from .IsMimeTypeValidator import IsMimeTypeValidator
3130
from .IsPastDateValidator import IsPastDateValidator
3231
from .IsPortValidator import IsPortValidator
3332
from .IsRgbColorValidator import IsRgbColorValidator

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
version="0.0.10",
66
author="Leander Cain Slotosch",
77
author_email="[email protected]",
8-
description="A library to filter and validate input data in"
8+
description="A library to filter and validate input data in "
99
"Flask applications",
1010
long_description=open("README.rst").read(),
1111
long_description_content_type="text/x-rst",

test/test_validator.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
IsJsonValidator,
3737
IsLowercaseValidator,
3838
IsMacAddressValidator,
39-
IsMimeTypeValidator,
4039
IsPastDateValidator,
4140
IsPortValidator,
4241
IsRgbColorValidator,
@@ -983,33 +982,6 @@ def test_is_mac_address_validator(self) -> None:
983982
with self.assertRaises(ValidationError):
984983
self.inputFilter.validateData({"mac2": "not_a_mac_address"})
985984

986-
def test_is_mime_type_validator(self) -> None:
987-
"""
988-
Test IsMimeTypeValidator.
989-
"""
990-
991-
self.inputFilter.add(
992-
"image",
993-
validators=[IsMimeTypeValidator()],
994-
)
995-
996-
# TODO
997-
# with open("test/data/base64_image.txt", "r") as file:
998-
# self.inputFilter.validateData({"image": file.read()})
999-
1000-
with self.assertRaises(ValidationError):
1001-
self.inputFilter.validateData({"image": "not_a_base64_image"})
1002-
1003-
self.inputFilter.add(
1004-
"image2",
1005-
validators=[
1006-
IsMimeTypeValidator(error_message="Custom error message")
1007-
],
1008-
)
1009-
1010-
with self.assertRaises(ValidationError):
1011-
self.inputFilter.validateData({"image2": "not_a_base64_image"})
1012-
1013985
def test_is_past_date_validator(self) -> None:
1014986
"""
1015987
Test IsPastDateValidator.

0 commit comments

Comments
 (0)