Value Object and Object Mother patterns implementation for Python
Project description
Sindripy
Value Object and Object Mother patterns for Python and Domain Driven Design applications
Easy use and customizable implementation for Value Object and Object Mother patterns.
Getting Started • Value Object Pattern • Object Mother Pattern
|
Sindri replaces ad hoc primitives and fragile validators with a consistent Value Object and Aggregate
toolkit you can adopt quickly.
Spin up validated value objects, aggregates, and test data with a simple and a small, focused API.
Sindripy provides a basic-high-customizable implementation to help you enforce domain invariants and improve code quality with minimal effort. Why use sindripy? Building your domain with Sindri lets you:
|
This project was generated using Instant Python, a fast, easy and reliable project generator for Python projects.
Navigation Guide
This section provides a high-level overview of the sindripy documentation so you can find quickly what you need.
For Users
For Developers
Need help?
- Join a discussion 💬 on GitHub Discussions
- Raise an issue on GitHub
Fast Kickstart
The latest version of sindripy can be installed from PyPI:
pip install sindripy
Here is a simple example of how to use sindri to create a value object and generate test data using an object mother.
from sindripy.value_objects import Integer, String
age = Integer(30)
name = String("John Doe")
print(f"Name: {name.value}, Age: {age.value}")
from sindripy.mothers import IntegerPrimitivesMother, StringPrimitivesMother
random_age = IntegerPrimitivesMother.any()
random_name = StringPrimitivesMother.any()
Migrating to v1.0.0
This release includes a breaking change to the validator API used by value objects:
- Validators no longer accept the incoming value as a parameter. Instead, the value is assigned to
self._valuebefore validators run, and validator methods have the signaturedef _validate_xxx(self) -> None:. - This simplifies validator signatures and reduces repetition across validation methods.
Why this is a breaking change
- Existing validator methods that still declare a
valueparameter will receive the wrong signature and raise aTypeErrorwhen the framework calls them. Custom code that expects the old parameter (for example, custom exception constructors or external utilities) may also need small updates.
How to migrate
- Follow the step-by-step migration guide which shows the exact edits and examples: Validator Signature Migration Guide.
- In short: find all methods decorated with
@validate, remove thevalueparameter, replace uses ofvaluewithself._value, and update any error messages or custom exceptions that referenced the old parameter.
A quick checklist:
- Update
@validatemethods todef _... (self) -> None - Replace
valuereferences withself._value - Update error messages and custom exception usages
- Run your tests
To learn more about advanced usage of value objects, including validation, custom value objects, complex objects like aggregates, visit the Value Object Pattern and Object Mother Pattern sections of the documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sindripy-1.0.1.tar.gz.
File metadata
- Download URL: sindripy-1.0.1.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b32c7529fade8a6a2308693f7404b796a9b6ba5b1b22c8945e1c9f7f8d707035
|
|
| MD5 |
161187c0bbaf046ed50dd18cdb54bde2
|
|
| BLAKE2b-256 |
a9949b266c7e427955a8edf0305ee932485be372ad4435a82a152138d8d2c937
|
Provenance
The following attestation bundles were made for sindripy-1.0.1.tar.gz:
Publisher:
release.yml on dimanu-py/sindri
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sindripy-1.0.1.tar.gz -
Subject digest:
b32c7529fade8a6a2308693f7404b796a9b6ba5b1b22c8945e1c9f7f8d707035 - Sigstore transparency entry: 919250719
- Sigstore integration time:
-
Permalink:
dimanu-py/sindri@a7ba31872bf7d160bda156a3ce7ad4e752a55bfc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dimanu-py
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a7ba31872bf7d160bda156a3ce7ad4e752a55bfc -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sindripy-1.0.1-py3-none-any.whl.
File metadata
- Download URL: sindripy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 26.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e4361214a942858e97f47383d7899f1b89c4434d3f6aeadc63531a3a2d2cb5c
|
|
| MD5 |
84a4d1a2287ff111b720ce64472cf853
|
|
| BLAKE2b-256 |
ffca54a047f006384880df22cfe7229e5e9c94bc6db651a52ada5114fbe04baf
|
Provenance
The following attestation bundles were made for sindripy-1.0.1-py3-none-any.whl:
Publisher:
release.yml on dimanu-py/sindri
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sindripy-1.0.1-py3-none-any.whl -
Subject digest:
6e4361214a942858e97f47383d7899f1b89c4434d3f6aeadc63531a3a2d2cb5c - Sigstore transparency entry: 919250721
- Sigstore integration time:
-
Permalink:
dimanu-py/sindri@a7ba31872bf7d160bda156a3ce7ad4e752a55bfc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dimanu-py
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a7ba31872bf7d160bda156a3ce7ad4e752a55bfc -
Trigger Event:
workflow_dispatch
-
Statement type: