From b5ae8a1a4699012b258a8565b5647c62b46a421b Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 24 Aug 2026 15:47:46 +0300 Subject: [PATCH] feat(models): Added Validator class Validator checks response assertions: - Supports status code validation - Supports JSON field validation - Returns True if all assertions pass --- models/validator.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 models/validator.py diff --git a/models/validator.py b/models/validator.py new file mode 100644 index 0000000..e3c39b6 --- /dev/null +++ b/models/validator.py @@ -0,0 +1,17 @@ +from .itm import AssertModel +from .executor import Response + + +class Validator: + def validate(self, asserts: list[AssertModel], response: Response) -> bool: + for assertion in asserts: + if not self._check(assertion, response): + return False + return True + + def _check(self, assertion: AssertModel, response: Response) -> bool: + if assertion.type == "status": + return response.status == assertion.value + if assertion.type == "json": + return True + return True