value-object-pattern 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- value_object_pattern-0.1.0/.gitignore +12 -0
- value_object_pattern-0.1.0/LICENSE.md +21 -0
- value_object_pattern-0.1.0/PKG-INFO +95 -0
- value_object_pattern-0.1.0/README.md +71 -0
- value_object_pattern-0.1.0/pyproject.toml +217 -0
- value_object_pattern-0.1.0/value_object_pattern/__init__.py +10 -0
- value_object_pattern-0.1.0/value_object_pattern/decorators/__init__.py +7 -0
- value_object_pattern-0.1.0/value_object_pattern/decorators/value_object_process.py +83 -0
- value_object_pattern-0.1.0/value_object_pattern/decorators/value_object_validation.py +78 -0
- value_object_pattern-0.1.0/value_object_pattern/models/__init__.py +3 -0
- value_object_pattern-0.1.0/value_object_pattern/models/value_object.py +383 -0
- value_object_pattern-0.1.0/value_object_pattern/py.typed +0 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/__init__.py +54 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/dates/__init__.py +9 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/dates/date/__init__.py +7 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/dates/date/date_value_object.py +162 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/dates/date/string_date_value_object.py +201 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/dates/datetime/__init__.py +7 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/dates/datetime/datetime_value_object.py +193 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/dates/datetime/string_datetime_value_object.py +237 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/identifiers/__init__.py +7 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/identifiers/country_ids/__init__.py +3 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/identifiers/country_ids/spain/__init__.py +3 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/identifiers/country_ids/spain/dni_value_object.py +63 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/identifiers/string_uuid_value_object.py +56 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/identifiers/uuid_value_object.py +40 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/__init__.py +38 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/api_keys/__init__.py +13 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/api_keys/aws_access_key_id_value_object.py +40 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/api_keys/aws_secret_access_key_value_object.py +40 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/api_keys/github_personal_access_token_value_object.py +41 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/api_keys/openai_api_key_value_object.py +40 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/api_keys/resend_api_key_value_object.py +40 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/aws_cloud_region_value_object.py +77 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/domain_value_object.py +149 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/host_value_object.py +143 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/ipv4_address_value_object.py +305 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/ipv4_network_value_object.py +165 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/ipv6_address_value_object.py +288 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/ipv6_network_value_object.py +145 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/mac_address_value_object.py +390 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/port_value_object.py +682 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/uri/__init__.py +11 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/uri/http_https_url_value_object.py +39 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/uri/http_url_value_object.py +39 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/uri/https_url_value_object.py +39 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/internet/uri/url_value_object.py +396 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/__init__.py +45 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/boolean/__init__.py +9 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/boolean/boolean_value_object.py +36 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/boolean/false_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/boolean/true_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/bytes/__init__.py +3 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/bytes/bytes_value_object.py +36 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/float/__init__.py +9 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/float/float_value_object.py +36 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/float/negative_float_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/float/positive_float_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/integer/__init__.py +13 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/integer/even_integer_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/integer/integer_value_object.py +36 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/integer/negative_integer_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/integer/odd_integer_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/integer/positive_integer_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/__init__.py +21 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/alpha_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/alphanumeric_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/digit_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/lowercase_string_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/non_empty_string_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/printable_string_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/string_value_object.py +36 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/trimmed_string_value_object.py +37 -0
- value_object_pattern-0.1.0/value_object_pattern/usables/primitives/string/uppercase_string_value_object.py +37 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) (2024-2025) adriamontoto
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,95 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: value-object-pattern
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: The Value Object Pattern is a Python package that streamlines the creation and management of value objects in your projects.
|
5
|
+
Project-URL: Homepage, https://github.com/adriamontoto/value-object-pattern
|
6
|
+
Project-URL: Repository, https://github.com/adriamontoto/value-object-pattern
|
7
|
+
Project-URL: Issues, https://github.com/adriamontoto/value-object-pattern/issues
|
8
|
+
Author: Adria Montoto
|
9
|
+
License-Expression: MIT
|
10
|
+
License-File: LICENSE.md
|
11
|
+
Keywords: development,domain-driven-design,encapsulation,pattern,python,tools,utilities,validation,value-object
|
12
|
+
Classifier: Intended Audience :: Developers
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
14
|
+
Classifier: Operating System :: OS Independent
|
15
|
+
Classifier: Programming Language :: Python
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
20
|
+
Classifier: Typing :: Typed
|
21
|
+
Requires-Python: >=3.11
|
22
|
+
Requires-Dist: python-dateutil>=2.9.0
|
23
|
+
Description-Content-Type: text/markdown
|
24
|
+
|
25
|
+
<a name="readme-top"></a>
|
26
|
+
|
27
|
+
# 📦 Value Object Pattern
|
28
|
+
|
29
|
+
<p align="center">
|
30
|
+
<a href="https://github.com/adriamontoto/value-object-pattern/actions/workflows/ci.yaml?event=push&branch=master" target="_blank">
|
31
|
+
<img src="https://github.com/adriamontoto/value-object-pattern/actions/workflows/ci.yaml/badge.svg?event=push&branch=master" alt="CI Pipeline">
|
32
|
+
</a>
|
33
|
+
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/adriamontoto/value-object-pattern" target="_blank">
|
34
|
+
<img src="https://coverage-badge.samuelcolvin.workers.dev/adriamontoto/value-object-pattern.svg" alt="Coverage Pipeline">
|
35
|
+
</a>
|
36
|
+
<a href="https://pypi.org/project/value-object-pattern" target="_blank">
|
37
|
+
<img src="https://img.shields.io/pypi/v/value-object-pattern?color=%2334D058&label=pypi%20package" alt="Package Version">
|
38
|
+
</a>
|
39
|
+
<a href="https://pypi.org/project/value-object-pattern/" target="_blank">
|
40
|
+
<img src="https://img.shields.io/pypi/pyversions/value-object-pattern.svg?color=%2334D058" alt="Supported Python Versions">
|
41
|
+
</a>
|
42
|
+
</p>
|
43
|
+
|
44
|
+
The **Value Object Pattern** is a Python 🐍 package that streamlines the creation and management of value objects 📦 in your projects. Value objects are immutable, self-validating objects that represent descriptive aspects of the domain with no conceptual identity. This pattern is essential for maintaining clean 🧹, maintainable, and bug-resistant 🐛 codebases by encapsulating domain-specific logic and ensuring consistency across your application 📱.
|
45
|
+
<br><br>
|
46
|
+
|
47
|
+
## Table of Contents
|
48
|
+
|
49
|
+
- [📥 Installation](#installation)
|
50
|
+
- [🤝 Contributing](#contributing)
|
51
|
+
- [🔑 License](#license)
|
52
|
+
|
53
|
+
<p align="right">
|
54
|
+
<a href="#readme-top">🔼 Back to top</a>
|
55
|
+
</p><br><br>
|
56
|
+
|
57
|
+
<a name="installation"></a>
|
58
|
+
|
59
|
+
## 📥 Installation
|
60
|
+
|
61
|
+
You can install **Value Object Pattern** using `pip`:
|
62
|
+
|
63
|
+
```bash
|
64
|
+
pip install value-object-pattern
|
65
|
+
```
|
66
|
+
|
67
|
+
<p align="right">
|
68
|
+
<a href="#readme-top">🔼 Back to top</a>
|
69
|
+
</p><br><br>
|
70
|
+
|
71
|
+
<a name="contributing"></a>
|
72
|
+
|
73
|
+
## 🤝 Contributing
|
74
|
+
|
75
|
+
We love community help! Before you open an issue or pull request, please read:
|
76
|
+
|
77
|
+
- [`🤝 How to Contribute`](https://github.com/adriamontoto/value-object-pattern/blob/master/.github/CONTRIBUTING.md)
|
78
|
+
- [`🧭 Code of Conduct`](https://github.com/adriamontoto/value-object-pattern/blob/master/.github/CODE_OF_CONDUCT.md)
|
79
|
+
- [`🔐 Security Policy`](https://github.com/adriamontoto/value-object-pattern/blob/master/.github/SECURITY.md)
|
80
|
+
|
81
|
+
_Thank you for helping make **📦 Value Object Pattern** package awesome! 🌟_
|
82
|
+
|
83
|
+
<p align="right">
|
84
|
+
<a href="#readme-top">🔼 Back to top</a>
|
85
|
+
</p><br><br>
|
86
|
+
|
87
|
+
<a name="license"></a>
|
88
|
+
|
89
|
+
## 🔑 License
|
90
|
+
|
91
|
+
This project is licensed under the terms of the [`MIT license`](https://github.com/adriamontoto/value-object-pattern/blob/master/LICENSE.md).
|
92
|
+
|
93
|
+
<p align="right">
|
94
|
+
<a href="#readme-top">🔼 Back to top</a>
|
95
|
+
</p>
|
@@ -0,0 +1,71 @@
|
|
1
|
+
<a name="readme-top"></a>
|
2
|
+
|
3
|
+
# 📦 Value Object Pattern
|
4
|
+
|
5
|
+
<p align="center">
|
6
|
+
<a href="https://github.com/adriamontoto/value-object-pattern/actions/workflows/ci.yaml?event=push&branch=master" target="_blank">
|
7
|
+
<img src="https://github.com/adriamontoto/value-object-pattern/actions/workflows/ci.yaml/badge.svg?event=push&branch=master" alt="CI Pipeline">
|
8
|
+
</a>
|
9
|
+
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/adriamontoto/value-object-pattern" target="_blank">
|
10
|
+
<img src="https://coverage-badge.samuelcolvin.workers.dev/adriamontoto/value-object-pattern.svg" alt="Coverage Pipeline">
|
11
|
+
</a>
|
12
|
+
<a href="https://pypi.org/project/value-object-pattern" target="_blank">
|
13
|
+
<img src="https://img.shields.io/pypi/v/value-object-pattern?color=%2334D058&label=pypi%20package" alt="Package Version">
|
14
|
+
</a>
|
15
|
+
<a href="https://pypi.org/project/value-object-pattern/" target="_blank">
|
16
|
+
<img src="https://img.shields.io/pypi/pyversions/value-object-pattern.svg?color=%2334D058" alt="Supported Python Versions">
|
17
|
+
</a>
|
18
|
+
</p>
|
19
|
+
|
20
|
+
The **Value Object Pattern** is a Python 🐍 package that streamlines the creation and management of value objects 📦 in your projects. Value objects are immutable, self-validating objects that represent descriptive aspects of the domain with no conceptual identity. This pattern is essential for maintaining clean 🧹, maintainable, and bug-resistant 🐛 codebases by encapsulating domain-specific logic and ensuring consistency across your application 📱.
|
21
|
+
<br><br>
|
22
|
+
|
23
|
+
## Table of Contents
|
24
|
+
|
25
|
+
- [📥 Installation](#installation)
|
26
|
+
- [🤝 Contributing](#contributing)
|
27
|
+
- [🔑 License](#license)
|
28
|
+
|
29
|
+
<p align="right">
|
30
|
+
<a href="#readme-top">🔼 Back to top</a>
|
31
|
+
</p><br><br>
|
32
|
+
|
33
|
+
<a name="installation"></a>
|
34
|
+
|
35
|
+
## 📥 Installation
|
36
|
+
|
37
|
+
You can install **Value Object Pattern** using `pip`:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
pip install value-object-pattern
|
41
|
+
```
|
42
|
+
|
43
|
+
<p align="right">
|
44
|
+
<a href="#readme-top">🔼 Back to top</a>
|
45
|
+
</p><br><br>
|
46
|
+
|
47
|
+
<a name="contributing"></a>
|
48
|
+
|
49
|
+
## 🤝 Contributing
|
50
|
+
|
51
|
+
We love community help! Before you open an issue or pull request, please read:
|
52
|
+
|
53
|
+
- [`🤝 How to Contribute`](https://github.com/adriamontoto/value-object-pattern/blob/master/.github/CONTRIBUTING.md)
|
54
|
+
- [`🧭 Code of Conduct`](https://github.com/adriamontoto/value-object-pattern/blob/master/.github/CODE_OF_CONDUCT.md)
|
55
|
+
- [`🔐 Security Policy`](https://github.com/adriamontoto/value-object-pattern/blob/master/.github/SECURITY.md)
|
56
|
+
|
57
|
+
_Thank you for helping make **📦 Value Object Pattern** package awesome! 🌟_
|
58
|
+
|
59
|
+
<p align="right">
|
60
|
+
<a href="#readme-top">🔼 Back to top</a>
|
61
|
+
</p><br><br>
|
62
|
+
|
63
|
+
<a name="license"></a>
|
64
|
+
|
65
|
+
## 🔑 License
|
66
|
+
|
67
|
+
This project is licensed under the terms of the [`MIT license`](https://github.com/adriamontoto/value-object-pattern/blob/master/LICENSE.md).
|
68
|
+
|
69
|
+
<p align="right">
|
70
|
+
<a href="#readme-top">🔼 Back to top</a>
|
71
|
+
</p>
|
@@ -0,0 +1,217 @@
|
|
1
|
+
[build-system]
|
2
|
+
requires = ['hatchling']
|
3
|
+
build-backend = 'hatchling.build'
|
4
|
+
|
5
|
+
|
6
|
+
[tool.hatch.version]
|
7
|
+
path = 'value_object_pattern/__init__.py'
|
8
|
+
|
9
|
+
[tool.hatch.build.targets.sdist]
|
10
|
+
include = ['value_object_pattern/']
|
11
|
+
|
12
|
+
|
13
|
+
[project]
|
14
|
+
name = 'value-object-pattern'
|
15
|
+
description = 'The Value Object Pattern is a Python package that streamlines the creation and management of value objects in your projects.'
|
16
|
+
readme = './README.md'
|
17
|
+
authors = [{ name = 'Adria Montoto' }]
|
18
|
+
license = 'MIT'
|
19
|
+
classifiers = [
|
20
|
+
'License :: OSI Approved :: MIT License',
|
21
|
+
'Intended Audience :: Developers',
|
22
|
+
'Operating System :: OS Independent',
|
23
|
+
'Typing :: Typed',
|
24
|
+
'Programming Language :: Python',
|
25
|
+
'Programming Language :: Python :: 3',
|
26
|
+
'Programming Language :: Python :: 3.11',
|
27
|
+
'Programming Language :: Python :: 3.12',
|
28
|
+
'Programming Language :: Python :: 3.13',
|
29
|
+
]
|
30
|
+
keywords = [
|
31
|
+
'python',
|
32
|
+
'development',
|
33
|
+
'tools',
|
34
|
+
'utilities',
|
35
|
+
'value-object',
|
36
|
+
'encapsulation',
|
37
|
+
'pattern',
|
38
|
+
'validation',
|
39
|
+
'domain-driven-design',
|
40
|
+
]
|
41
|
+
requires-python = '>=3.11'
|
42
|
+
dependencies = ['python-dateutil>=2.9.0']
|
43
|
+
dynamic = ['version']
|
44
|
+
|
45
|
+
[project.urls]
|
46
|
+
Homepage = 'https://github.com/adriamontoto/value-object-pattern'
|
47
|
+
Repository = 'https://github.com/adriamontoto/value-object-pattern'
|
48
|
+
Issues = 'https://github.com/adriamontoto/value-object-pattern/issues'
|
49
|
+
|
50
|
+
|
51
|
+
[dependency-groups]
|
52
|
+
audit = ['pip-audit>=2.9.0']
|
53
|
+
coverage = ['coverage[toml]>=7.0.0', 'smokeshow>=0.5.0']
|
54
|
+
develop = ['pre-commit>=3.0.0']
|
55
|
+
format = ['ruff>=0.11.10']
|
56
|
+
lint = [
|
57
|
+
'ruff>=0.11.10',
|
58
|
+
'mypy[reports]>=1.0.0',
|
59
|
+
{ include-group = 'test' },
|
60
|
+
{ include-group = 'types' },
|
61
|
+
]
|
62
|
+
release = ['build>=1.2.2', 'python-semantic-release>=10.0.2']
|
63
|
+
test = [
|
64
|
+
'pytest>=8.0.0',
|
65
|
+
'pytest-randomly>=3.0.0',
|
66
|
+
'object-mother-pattern>=1.0.0',
|
67
|
+
{ include-group = 'coverage' },
|
68
|
+
]
|
69
|
+
types = ['types-python-dateutil>=2.9.0.20241206 ']
|
70
|
+
all = [
|
71
|
+
{ include-group = 'audit' },
|
72
|
+
{ include-group = 'coverage' },
|
73
|
+
{ include-group = 'develop' },
|
74
|
+
{ include-group = 'format' },
|
75
|
+
{ include-group = 'lint' },
|
76
|
+
{ include-group = 'release' },
|
77
|
+
{ include-group = 'test' },
|
78
|
+
{ include-group = 'types' },
|
79
|
+
]
|
80
|
+
|
81
|
+
|
82
|
+
[tool.pytest.ini_options]
|
83
|
+
pythonpath = '.'
|
84
|
+
addopts = [
|
85
|
+
'--strict-config', # fail if an unregistered option is used
|
86
|
+
'--strict-markers', # fail if an unregistered marker is used
|
87
|
+
'--color=yes', # color the output
|
88
|
+
]
|
89
|
+
markers = ['unit_testing: Check a unique functionality']
|
90
|
+
xfail_strict = true
|
91
|
+
|
92
|
+
|
93
|
+
[tool.coverage.run]
|
94
|
+
source = ['value_object_pattern']
|
95
|
+
parallel = true
|
96
|
+
branch = true
|
97
|
+
relative_files = true
|
98
|
+
|
99
|
+
[tool.coverage.report]
|
100
|
+
show_missing = true
|
101
|
+
skip_covered = true
|
102
|
+
precision = 2
|
103
|
+
exclude_lines = [
|
104
|
+
'pragma: no cover',
|
105
|
+
'raise NotImplementedError',
|
106
|
+
'if TYPE_CHECKING:',
|
107
|
+
'if typing.TYPE_CHECKING:',
|
108
|
+
'@overload',
|
109
|
+
'@typing.overload',
|
110
|
+
'typing.assert_never',
|
111
|
+
'assert_never',
|
112
|
+
]
|
113
|
+
|
114
|
+
[tool.coverage.paths]
|
115
|
+
source = ['value_object_pattern']
|
116
|
+
|
117
|
+
|
118
|
+
[tool.ruff]
|
119
|
+
indent-width = 4
|
120
|
+
line-length = 120
|
121
|
+
target-version = 'py313'
|
122
|
+
output-format = 'grouped'
|
123
|
+
|
124
|
+
[tool.ruff.format]
|
125
|
+
docstring-code-format = true
|
126
|
+
docstring-code-line-length = 120
|
127
|
+
indent-style = 'space'
|
128
|
+
quote-style = 'single'
|
129
|
+
skip-magic-trailing-comma = false
|
130
|
+
|
131
|
+
[tool.ruff.lint]
|
132
|
+
select = [
|
133
|
+
'F', # pyflakes
|
134
|
+
'S', # flake8-bandit
|
135
|
+
'B', # flake8-bugbear
|
136
|
+
'DTZ', # flake8-datetimez
|
137
|
+
'C4', # flake8-comprehensions
|
138
|
+
'SIM', # flake8-simplify
|
139
|
+
'I', # isort
|
140
|
+
'C90', # mccabe
|
141
|
+
'N', # pep8-naming
|
142
|
+
'PERF', # perflint
|
143
|
+
'E', # pycodestyle
|
144
|
+
'W', # pycodestyle
|
145
|
+
'D', # pydocstyle
|
146
|
+
'UP', # pyupgrade
|
147
|
+
'RUF', # ruff
|
148
|
+
]
|
149
|
+
ignore = [
|
150
|
+
'UP035', # Checks for uses of deprecated imports based on the minimum supported Python version.
|
151
|
+
'UP036', # Checks for conditional blocks gated on sys.version_info comparisons that are outdated for the minimum supported Python version.
|
152
|
+
'E111', # Checks for indentation with a non-multiple of 4 spaces.
|
153
|
+
'E114', # Checks for indentation of comments with a non-multiple of 4 spaces.
|
154
|
+
'E117', # Checks for over-indented code.
|
155
|
+
'W191', # Checks for indentation that uses tabs.
|
156
|
+
'D200', # Checks for single-line docstrings that are broken across multiple lines.
|
157
|
+
'D205', # 1 blank line required between summary line and description.
|
158
|
+
'D206', # Checks for docstrings that are indented with tabs.
|
159
|
+
'D212', # Checks for docstring summary lines that are not positioned on the first physical line of the docstring.
|
160
|
+
'D401', # First line of docstring should be in imperative mood.
|
161
|
+
'D300', # Checks for docstrings that use '''triple single quotes''' instead of 'triple double quotes'.
|
162
|
+
'RUF100', # Checks for unused noqa directives.
|
163
|
+
]
|
164
|
+
|
165
|
+
[tool.ruff.lint.per-file-ignores]
|
166
|
+
'__init__.py' = [
|
167
|
+
'F401', # Checks for unused imports.
|
168
|
+
'D104', # Checks for undocumented public package definitions.
|
169
|
+
]
|
170
|
+
'**test**.py' = [
|
171
|
+
'S101', # Use of `assert` detected.
|
172
|
+
]
|
173
|
+
|
174
|
+
[tool.ruff.lint.mccabe]
|
175
|
+
max-complexity = 10
|
176
|
+
|
177
|
+
[tool.ruff.lint.pydocstyle]
|
178
|
+
convention = 'pep257'
|
179
|
+
|
180
|
+
[tool.ruff.lint.isort]
|
181
|
+
case-sensitive = true
|
182
|
+
known-first-party = ['value_object_pattern']
|
183
|
+
combine-as-imports = true
|
184
|
+
|
185
|
+
|
186
|
+
[tool.mypy]
|
187
|
+
strict = true
|
188
|
+
warn_unreachable = true
|
189
|
+
enable_error_code = [
|
190
|
+
'redundant-expr',
|
191
|
+
'possibly-undefined',
|
192
|
+
'truthy-bool',
|
193
|
+
'explicit-override',
|
194
|
+
]
|
195
|
+
|
196
|
+
|
197
|
+
[tool.semantic_release]
|
198
|
+
allow_zero_version = true
|
199
|
+
commit_message = 'bump: new version {version} released'
|
200
|
+
commit_parser = 'conventional'
|
201
|
+
major_on_zero = true
|
202
|
+
no_git_verify = false
|
203
|
+
tag_format = 'v{version}'
|
204
|
+
version_variables = ['value_object_pattern/__init__.py:__version__']
|
205
|
+
|
206
|
+
[tool.semantic_release.commit_parser_options]
|
207
|
+
minor_tags = ['feat']
|
208
|
+
patch_tags = ['fix', 'perf', 'build']
|
209
|
+
allowed_tags = ['feat', 'fix', 'perf', 'build']
|
210
|
+
default_bump_level = 0
|
211
|
+
parse_squash_commits = false
|
212
|
+
ignore_merge_commits = true
|
213
|
+
|
214
|
+
[tool.semantic_release.changelog]
|
215
|
+
template_dir = 'docs/changelog_template'
|
216
|
+
mode = 'update'
|
217
|
+
exclude_commit_patterns = ['''Merged? .*''']
|
@@ -0,0 +1,83 @@
|
|
1
|
+
"""
|
2
|
+
Process decorator for value object pattern.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from functools import wraps
|
6
|
+
from typing import Any, Callable, TypeVar
|
7
|
+
|
8
|
+
T = TypeVar('T')
|
9
|
+
|
10
|
+
|
11
|
+
def process(order: int | None = None) -> Callable[[Callable[..., T]], Callable[..., T]]:
|
12
|
+
"""
|
13
|
+
Decorator for process the value after the value is validated.
|
14
|
+
|
15
|
+
Args:
|
16
|
+
order (int | None, optional): The order of the process that will be executed, if None the functions will be
|
17
|
+
executed alphabetically. Defaults to None.
|
18
|
+
|
19
|
+
Raises:
|
20
|
+
TypeError: If the order is not an integer.
|
21
|
+
ValueError: If the order is not equal or greater than 0.
|
22
|
+
|
23
|
+
Returns:
|
24
|
+
Callable[[Callable[..., T]], Callable[..., T]]: Wrapper function for the process.
|
25
|
+
|
26
|
+
Example:
|
27
|
+
```python
|
28
|
+
from value_object_pattern import ValueObject, process
|
29
|
+
|
30
|
+
|
31
|
+
class UpperStringValueObject(ValueObject[str]):
|
32
|
+
@process()
|
33
|
+
def ensure_value_is_upper(self, value: str) -> str:
|
34
|
+
return value.upper()
|
35
|
+
|
36
|
+
|
37
|
+
string = UpperStringValueObject(value='hello world')
|
38
|
+
print(string)
|
39
|
+
# >>> HELLO WORLD
|
40
|
+
```
|
41
|
+
"""
|
42
|
+
|
43
|
+
def decorator(function: Callable[..., T]) -> Callable[..., T]:
|
44
|
+
"""
|
45
|
+
Decorator for process the value after the value is validated.
|
46
|
+
|
47
|
+
Args:
|
48
|
+
function (Callable[..., T]): Function to be execution after the value object is validated.
|
49
|
+
|
50
|
+
Raises:
|
51
|
+
TypeError: If the order is not an integer.
|
52
|
+
ValueError: If the order is not equal or greater than 0.
|
53
|
+
|
54
|
+
Returns:
|
55
|
+
Callable[..., T]: Wrapper function for the process.
|
56
|
+
"""
|
57
|
+
if order is not None:
|
58
|
+
if type(order) is not int:
|
59
|
+
raise TypeError(f'Process order <<<{order}>>> must be an integer. Got <<<{type(order).__name__}>>> type.') # noqa: E501 # fmt: skip
|
60
|
+
|
61
|
+
if order < 0:
|
62
|
+
raise ValueError(f'Process order <<<{order}>>> must be equal or greater than 0.')
|
63
|
+
|
64
|
+
function._is_process = True # type: ignore[attr-defined]
|
65
|
+
function._order = function.__name__ if order is None else str(order) # type: ignore[attr-defined]
|
66
|
+
|
67
|
+
@wraps(wrapped=function)
|
68
|
+
def wrapper(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> T:
|
69
|
+
"""
|
70
|
+
Wrapper for process.
|
71
|
+
|
72
|
+
Args:
|
73
|
+
*args (tuple[Any, ...]): The arguments for the function.
|
74
|
+
**kwargs (dict[str, Any]): The keyword arguments for the function.
|
75
|
+
|
76
|
+
Returns:
|
77
|
+
T: The return value of the function.
|
78
|
+
"""
|
79
|
+
return function(*args, **kwargs)
|
80
|
+
|
81
|
+
return wrapper
|
82
|
+
|
83
|
+
return decorator
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"""
|
2
|
+
Validation decorator for value object pattern.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from functools import wraps
|
6
|
+
from typing import Any, Callable
|
7
|
+
|
8
|
+
|
9
|
+
def validation(order: int | None = None) -> Callable[[Callable[..., None]], Callable[..., None]]:
|
10
|
+
"""
|
11
|
+
Decorator for validation the value before the value is created.
|
12
|
+
|
13
|
+
Args:
|
14
|
+
order (int | None, optional): The order of the validation that will be executed, if None the functions will be
|
15
|
+
executed alphabetically. Defaults to None.
|
16
|
+
|
17
|
+
Raises:
|
18
|
+
TypeError: If the order is not an integer.
|
19
|
+
ValueError: If the order is not equal or greater than 0.
|
20
|
+
|
21
|
+
Returns:
|
22
|
+
Callable[[Callable[..., None]], Callable[..., None]]: Wrapper function for the validation.
|
23
|
+
|
24
|
+
Example:
|
25
|
+
```python
|
26
|
+
from value_object_pattern import ValueObject, validation
|
27
|
+
|
28
|
+
|
29
|
+
class IntegerValueObject(ValueObject[int]):
|
30
|
+
@validation()
|
31
|
+
def ensure_value_is_integer(self, value: int) -> None:
|
32
|
+
if type(value) is not int:
|
33
|
+
raise TypeError(f'IntegerValueObject value <<<{value}>>> must be an integer. Got <<<{type(value).__name__}>>> type.')
|
34
|
+
|
35
|
+
|
36
|
+
integer = IntegerValueObject(value='invalid')
|
37
|
+
# >>> TypeError: IntegerValueObject value <<<invalid>>> must be an integer. Got <<<str>>> type.
|
38
|
+
```
|
39
|
+
""" # noqa: E501 # fmt: skip
|
40
|
+
|
41
|
+
def decorator(function: Callable[..., None]) -> Callable[..., None]:
|
42
|
+
"""
|
43
|
+
Decorator for validation the value before the value is created.
|
44
|
+
|
45
|
+
Args:
|
46
|
+
function (Callable[..., None]): Function to be execution before the value object is created.
|
47
|
+
|
48
|
+
Raises:
|
49
|
+
TypeError: If the order is not an integer.
|
50
|
+
ValueError: If the order is not equal or greater than 0.
|
51
|
+
|
52
|
+
Returns:
|
53
|
+
Callable[..., None]: Wrapper function for the validation.
|
54
|
+
"""
|
55
|
+
if order is not None:
|
56
|
+
if type(order) is not int:
|
57
|
+
raise TypeError(f'Validation order <<<{order}>>> must be an integer. Got <<<{type(order).__name__}>>> type.') # noqa: E501 # fmt: skip
|
58
|
+
|
59
|
+
if order < 0:
|
60
|
+
raise ValueError(f'Validation order <<<{order}>>> must be equal or greater than 0.')
|
61
|
+
|
62
|
+
function._is_validation = True # type: ignore[attr-defined]
|
63
|
+
function._order = function.__name__ if order is None else str(order) # type: ignore[attr-defined]
|
64
|
+
|
65
|
+
@wraps(wrapped=function)
|
66
|
+
def wrapper(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> None:
|
67
|
+
"""
|
68
|
+
Wrapper for validation.
|
69
|
+
|
70
|
+
Args:
|
71
|
+
*args (tuple[Any, ...]): The arguments for the function.
|
72
|
+
**kwargs (dict[str, Any]): The keyword arguments for the function.
|
73
|
+
"""
|
74
|
+
function(*args, **kwargs)
|
75
|
+
|
76
|
+
return wrapper
|
77
|
+
|
78
|
+
return decorator
|