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

LeanderCS / flask-inputfilter / #50

14 Jan 2025 09:28PM UTC coverage: 96.916%. Remained the same
#50

Pull #11

coveralls-python

LeanderCS
10 | Add mounting in workflow to transfer the coverage data correctly
Pull Request #11: 10 | Add testing for all supportet python versions

1037 of 1070 relevant lines covered (96.92%)

0.97 hits per line

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

95.0
/flask_inputfilter/Validator/ArrayElementValidator.py
1
from typing import TYPE_CHECKING, Any
1✔
2

3
from ..Exception import ValidationError
1✔
4
from .BaseValidator import BaseValidator
1✔
5

6
if TYPE_CHECKING:
1✔
7
    from ..InputFilter import InputFilter
×
8

9

10
class ArrayElementValidator(BaseValidator):
1✔
11
    """
12
    Validator to validate each element in an array.
13
    """
14

15
    def __init__(
1✔
16
        self,
17
        elementFilter: "InputFilter",
18
        error_message: str = "Value '{}' is not in '{}'",
19
    ) -> None:
20
        self.elementFilter = elementFilter
1✔
21
        self.error_message = error_message
1✔
22

23
    def validate(self, value: Any) -> None:
1✔
24
        if not isinstance(value, list):
1✔
25
            raise ValidationError("Value is not an array")
1✔
26

27
        for i, element in enumerate(value):
1✔
28
            try:
1✔
29
                validated_element = self.elementFilter.validateData(element)
1✔
30
                value[i] = validated_element
1✔
31

32
            except ValidationError:
1✔
33
                if "{}" in self.error_message:
1✔
34
                    raise ValidationError(
1✔
35
                        self.error_message.format(element, self.elementFilter)
36
                    )
37

38
                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

© 2025 Coveralls, Inc