Skip to main content

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:

  • ⏱️ Cut domain modeling and validation to seconds
  • 🛡️ Declare immutable, validated value objects with clear error messages
  • 🧩 Model aggregates with explicit invariants and composition
  • 🧪 Generate realistic test data via the Object Mother pattern
  • 🧰 Start from ready made primitives and identifiers or extend with your own
  • 🔧 Plug in custom validators, decorators, and typed primitives
💧
Created with Instant Python
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?

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._value before validators run, and validator methods have the signature def _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 value parameter will receive the wrong signature and raise a TypeError when 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 the value parameter, replace uses of value with self._value, and update any error messages or custom exceptions that referenced the old parameter.

A quick checklist:

  • Update @validate methods to def _... (self) -> None
  • Replace value references with self._value
  • Update error messages and custom exception usages
  • Run your tests
ℹ️
Learn More
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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sindripy-1.0.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sindripy-1.0.0-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file sindripy-1.0.0.tar.gz.

File metadata

  • Download URL: sindripy-1.0.0.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

Hashes for sindripy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 aa35bfff8ea23377681795314cf2886ff88adbc99aad0fb317f805adc42f3c07
MD5 df7a8bfca52acc97b6ef8201c2f68a4e
BLAKE2b-256 be37df3bcd3b32672670638b8fd6334ea5c8610a1195c3a0d1d9a519e5de2006

See more details on using hashes here.

Provenance

The following attestation bundles were made for sindripy-1.0.0.tar.gz:

Publisher: release.yml on dimanu-py/sindri

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sindripy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sindripy-1.0.0-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

Hashes for sindripy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f05c4d9bfc9694bcd0d7d211b3592eb33d38e78273c0ae669afda727716e020
MD5 29d222ea70abca16f71d1b2df21e6a52
BLAKE2b-256 95075b3afc47135ceb8c1b06bb96acd64599699f7557892de604718e0e081813

See more details on using hashes here.

Provenance

The following attestation bundles were made for sindripy-1.0.0-py3-none-any.whl:

Publisher: release.yml on dimanu-py/sindri

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page