Python value object implementation
Project description
About
Abstract base class for python value objects.
Usage
Extend and implement the is_valid method.
class Weight(ValueObject):
def is_valid(self, value: int) -> bool:
return isinstance(value, int) and value >= 0
Equality example:
o = Weight(10)
p = Weight(11)
q = Weight(11)
print('o ', o)
print('p ', p)
print('q ', q)
print('o == p ', o == p)
print('o == q ', o == q)
print('p == q ', p == q)
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.