From: Aleš Mrázek Date: Tue, 24 Feb 2026 10:38:09 +0000 (+0100) Subject: python: modeling: added validation context X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5705d52100bc2176b01353dab363fb0cd108b26e;p=thirdparty%2Fknot-resolver.git python: modeling: added validation context --- diff --git a/python/knot_resolver/utils/modeling/context.py b/python/knot_resolver/utils/modeling/context.py new file mode 100644 index 000000000..309942e6a --- /dev/null +++ b/python/knot_resolver/utils/modeling/context.py @@ -0,0 +1,39 @@ +from __future__ import annotations + +from dataclasses import dataclass +from enum import IntEnum + + +class Strictness(IntEnum): + """ + Data validation strictness. + + Attributes: + PERMISSIVE: Validation that the input data corresponds to the structure of the data model. + BASIC: PERMISSIVE validation plus validation of input data types and values. + NORMAL: BASIC validation plus validation of the context between individual parts of the data. + For example, mutually exclusive values. + STRICT: NORMAL validation plus validation of things outside the data. + For example, checking the existence of file/directory. + """ + + PERMISSIVE = 1 + BASIC = 2 + NORMAL = 3 + STRICT = 4 + + +@dataclass +class Context: + """ + Base validation context for data validation operations. + + Attributes: + username: The user name for which permissions are to be checked. + groupname: The group name for which permissions are to be checked. + strictness: Level of data validation strictness. + """ + + username: str | None = None + groupname: str | None = None + strictness: Strictness = Strictness.NORMAL