flask_boilerplate.domain.value_objects package
Submodules
flask_boilerplate.domain.value_objects.value_object_example module
- class flask_boilerplate.domain.value_objects.value_object_example.ValueObjectExample(name: str, description: str)[source]
Bases:
ValueObjectAn example value object in the domain layer. This value object represents a domain object with attributes that define its state. It encapsulates business logic related to its attributes.
- name
The name of the value object.
- Type:
str
- description
A description of the value object.
- Type:
str
- __eq__(other: Any) bool[source]
Compare two value objects based on their attributes.
- Parameters:
other (Any) – The other value object to compare with.
- Returns:
True if the value objects have the same attributes, False otherwise.
- Return type:
bool
- __hash__() int[source]
Generate a hash value for the value object based on its attributes.
- Returns:
The hash value of the value object.
- Return type:
int
- description: str
- name: str
- validate() None[source]
Validate the value object’s data.
- Raises:
ValueObjectsError – If the value object’s data is invalid.
Module contents
Module for exporting value objects in the domain layer.
This module serves as the entry point for all value objects in the domain layer. It re-exports value objects to make them easily accessible from a single location.
Value objects are domain objects that are defined by their attributes rather than their identity. They are immutable and can be compared based on their attributes.
Example
>>> from flask_boilerplate.domain.value_objects import ValueObjectExample
>>> value_object = ValueObjectExample(name="Example", description="An example value object")
>>> print(value_object.attribute1)
"value1"
- class flask_boilerplate.domain.value_objects.ValueObjectExample(name: str, description: str)[source]
Bases:
ValueObjectAn example value object in the domain layer. This value object represents a domain object with attributes that define its state. It encapsulates business logic related to its attributes.
- name
The name of the value object.
- Type:
str
- description
A description of the value object.
- Type:
str
- __eq__(other: Any) bool[source]
Compare two value objects based on their attributes.
- Parameters:
other (Any) – The other value object to compare with.
- Returns:
True if the value objects have the same attributes, False otherwise.
- Return type:
bool
- __hash__() int[source]
Generate a hash value for the value object based on its attributes.
- Returns:
The hash value of the value object.
- Return type:
int
- description: str
- name: str
- validate() None[source]
Validate the value object’s data.
- Raises:
ValueObjectsError – If the value object’s data is invalid.