python_technical_primitives.patterns.base¶
Base Specification class for DIY Specification pattern. No external dependencies - we own this code.
Attributes¶
Classes¶
Base class for all specifications. |
Module Contents¶
- python_technical_primitives.patterns.base.T¶
- class python_technical_primitives.patterns.base.Specification¶
Bases:
abc.ABC,Generic[T]Base class for all specifications. Supports boolean composition (&, |, ~) and error tracking.
- Example:
>>> class AdultSpec(Specification[User]): ... description = "User must be 18+" ... def is_satisfied_by(self, user): ... return user.age >= 18 >>> >>> spec = AdultSpec() & VerifiedEmailSpec() >>> if spec(user): ... process_user(user)
- description: str = 'No description provided.'¶
- abstract is_satisfied_by(candidate: T) bool¶
Check if candidate satisfies specification.
- property errors: Dict[str, str]¶
Get errors from last validation.