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

patrickboateng / func-validator / 19454419020

18 Nov 2025 04:41AM UTC coverage: 97.882% (-0.1%) from 97.993%
19454419020

push

github

patrickboateng
fixed bugs and reformatted files

44 of 44 branches covered (100.0%)

Branch coverage included in aggregate %.

21 of 22 new or added lines in 7 files covered. (95.45%)

13 existing lines in 1 file now uncovered.

788 of 806 relevant lines covered (97.77%)

1.96 hits per line

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

95.24
/func_validator/validators/_core.py
1
from abc import ABC, abstractmethod
2✔
2
from string import Template
2✔
3
from typing import Optional, TypeAlias, TypeVar
2✔
4

5
__all__ = [
2✔
6
    "Number",
7
    "OPERATOR_SYMBOLS",
8
    "T",
9
    "ErrorMsg",
10
    "Validator",
11
    "ValidationError",
12
]
13

14
Number: TypeAlias = int | float
2✔
15
T = TypeVar("T")
2✔
16

17
OPERATOR_SYMBOLS: dict[str, str] = {
2✔
18
    "eq": "==",
19
    "ge": ">=",
20
    "gt": ">",
21
    "le": "<=",
22
    "lt": "<",
23
    "ne": "!=",
24
    "isclose": "≈",
25
}
26

27

28
class ValidationError(Exception):
2✔
29
    pass
2✔
30

31

32
class ErrorMsg(Template):
2✔
33
    def transform(self, **kwargs):
2✔
34
        return self.safe_substitute(kwargs)
2✔
35

36

37
class Validator(ABC):
2✔
38

39
    def __init__(self, *, err_msg: str | ErrorMsg = "") -> None:
2✔
40
        if isinstance(err_msg, str):
2✔
41
            self.err_msg = ErrorMsg(err_msg)
2✔
42
        elif isinstance(err_msg, ErrorMsg):
2✔
43
            self.err_msg = err_msg
2✔
44
        else:
NEW
45
            raise ValidationError(
×
46
                f"err_msg must be str or ErrorMsg, not {type(err_msg)}"
47
            )
48

49
    @abstractmethod
50
    def __call__(self, *args, **kwargs) -> T: ...
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