• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LeanderCS / flask-inputfilter / #72

18 Jan 2025 10:38PM UTC coverage: 98.065% (-1.2%) from 99.252%
#72

push

coveralls-python

web-flow
Merge pull request #21 from LeanderCS/17

17 | Add new filters and validators

156 of 173 new or added lines in 11 files covered. (90.17%)

1216 of 1240 relevant lines covered (98.06%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
/flask_inputfilter/Validator/IsHorizontalImageValidator.py
1
import base64
1✔
2
import io
1✔
3

4
from PIL import Image
1✔
5
from PIL.Image import Image as ImageType
1✔
6

7
from flask_inputfilter.Exception import ValidationError
1✔
8
from flask_inputfilter.Validator import BaseValidator
1✔
9

10

11
class IsHorizontalImageValidator(BaseValidator):
1✔
12
    def __init__(self, error_message=None):
1✔
13
        self.error_message = (
1✔
14
            error_message or "The image is not horizontically oriented."
15
        )
16

17
    def validate(self, value):
1✔
18
        if not isinstance(value, (str, ImageType)):
1✔
NEW
19
            raise ValidationError(
×
20
                "The value is not an image or its base 64 representation."
21
            )
22

23
        try:
1✔
24
            if isinstance(value, str):
1✔
25
                value = Image.open(io.BytesIO(base64.b64decode(value)))
1✔
26

27
            if value.width < value.height:
1✔
28
                raise
1✔
29

30
        except Exception:
1✔
31
            raise ValidationError(self.error_message)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc