PORTUGUÊS | [ENGLISH](https://github.com/fazedordecodigo/PyFlunt/blob/main/README_EN.md)
# 🐍 PyFlunt: Domain Notification Pattern
Implementação Python inspirada no [Flunt](https://github.com/andrebaltieri/flunt) (.NET)
[![Último Lançamento no PyPI](https://img.shields.io/pypi/v/flunt.svg)](https://pypi.org/project/flunt/)
[![python](https://img.shields.io/pypi/pyversions/flunt.svg)](https://pypi.org/project/flunt/)
[![Downloads](https://static.pepy.tech/badge/flunt/month)](https://pepy.tech/project/flunt)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Discord](https://img.shields.io/discord/1211477389830393866?logo=discord&label=Discord&color=5865F2&logoColor=white)](https://discord.gg/HNwFHQWX)
[![Avaliação de Segurança](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)
[![Avaliação de Confiabilidade](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)
[![Avaliação de Manutenibilidade](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=bugs)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)
[![Vulnerabilidades](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)
Flunt te auxilia a implementar Domain Notification Pattern em sua aplicação para centralizar erros e mudanças em determinadas ações e entidades.
Flunt surgiu de duas necessidades: implementar o Domain Notification Pattern para substituir exceções no nível de domínio da aplicação e reduzir a quantidade de IFs (complexidade) usando uma abordagem baseada em contratos.
Assim, basicamente o que o Flunt faz é adicionar uma lista de Notificações à sua classe e vários métodos para interagir com ela.
## ➡️ Como usar
### 🔧 Instalação
````bash
pip install flunt
````
### 🔔 Notifiable
````python
from flunt.notifications.notifiable import Notifiable
from flunt.validations.contract import Contract
class Nome(Notifiable):
def __init__(self, nome):
super().__init__()
if len(nome) > 3:
self.add_notification(
Notification(field='nome', message='nome inválido')
)
self._nome = nome
````
### 📜 Contract
````python
"""Módulo Objetos de Valor."""
from flunt.notifications.notifiable import Notifiable
from flunt.validations.contract import Contract
class Nome(Notifiable):
"""Classe Objeto de Valor Nome."""
def __init__(self, primeiro_nome, ultimo_nome):
"""Encontrar 'Construtor'."""
super().__init__()
self.primeiro_nome = primeiro_nome
self.ultimo_nome = ultimo_nome
self.add_notifications(
Contract()
.requires(self.primeiro_nome, 'primeiro nome')
.requires(self.ultimo_nome, 'último nome')
.is_greater_than(
value=self.primeiro_nome,
comparer=3,
key="primeiro_nome",
message="Mínimo de 3 caracteres",
)
.is_greater_than(
value=self.ultimo_nome,
comparer=3,
key="ultimo_nome",
message="Mínimo de 3 caracteres",
)
.get_notifications()
)
nome = Nome('Emerson', 'Delatorre')
if not nome.is_valid():
for notification in nome.get_notifications():
print(notification)
````
## Contribuindo
Consulte nosso DevGuide no link a seguir: [CONTRIBUTING](https://github.com/fazedordecodigo/PyFlunt/blob/main/README.md/CONTRIBUTING.md)
## Registro de Alterações
Consulte nosso registro de alterações no link a seguir: [CHANGELOG](https://github.com/fazedordecodigo/PyFlunt/blob/main/README.md/CHANGELOG.md)
## 📄 Licença
Este projeto contém a licença MIT. Consulte o arquivo [LICENSE](https://github.com/fazedordecodigo/PyFlunt/blob/main/README.md/LICENSE).
## Mods
* [Flunt para C# (Original)](https://github.com/andrebaltieri/Flunt)
* [Flunt.Br](https://github.com/lira92/flunt.br)
* [Flunt para Java](https://github.com/carlosbritojun/jflunt)
* [Flunt para JavaScript](https://github.com/jhonesgoncal/flunt)
* [Flunt para PHP](https://github.com/matheusbloise/flunt-php)
Raw data
{
"_id": null,
"home_page": "https://github.com/Delatorrea/PyFlunt",
"name": "Flunt",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "notifications,python,ddd,python3,validations,notification,ddd-patterns,ddd-architecture,validation-library,class-validator,fluentvalidation,class-validation,flunt,domain-notification,class-validator-cpf",
"author": "Emerson Delatorre",
"author_email": "38289677+Delatorrea@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/8b/d6/910a7281adc5bc17e4d07d8ac8f0617b2131ed61539288dff31a152c09e9/flunt-2.3.0.tar.gz",
"platform": null,
"description": "PORTUGU\u00caS | [ENGLISH](https://github.com/fazedordecodigo/PyFlunt/blob/main/README_EN.md)\n\n# \ud83d\udc0d PyFlunt: Domain Notification Pattern\n\nImplementa\u00e7\u00e3o Python inspirada no [Flunt](https://github.com/andrebaltieri/flunt) (.NET)\n\n[![\u00daltimo Lan\u00e7amento no PyPI](https://img.shields.io/pypi/v/flunt.svg)](https://pypi.org/project/flunt/)\n[![python](https://img.shields.io/pypi/pyversions/flunt.svg)](https://pypi.org/project/flunt/)\n[![Downloads](https://static.pepy.tech/badge/flunt/month)](https://pepy.tech/project/flunt)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Discord](https://img.shields.io/discord/1211477389830393866?logo=discord&label=Discord&color=5865F2&logoColor=white)](https://discord.gg/HNwFHQWX)\n\n\n[![Avalia\u00e7\u00e3o de Seguran\u00e7a](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)\n[![Avalia\u00e7\u00e3o de Confiabilidade](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)\n[![Avalia\u00e7\u00e3o de Manutenibilidade](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=bugs)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)\n[![Vulnerabilidades](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=fazedordecodigo_PyFlunt&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=fazedordecodigo_PyFlunt)\n\n\nFlunt te auxilia a implementar Domain Notification Pattern em sua aplica\u00e7\u00e3o para centralizar erros e mudan\u00e7as em determinadas a\u00e7\u00f5es e entidades.\n\nFlunt surgiu de duas necessidades: implementar o Domain Notification Pattern para substituir exce\u00e7\u00f5es no n\u00edvel de dom\u00ednio da aplica\u00e7\u00e3o e reduzir a quantidade de IFs (complexidade) usando uma abordagem baseada em contratos.\n\nAssim, basicamente o que o Flunt faz \u00e9 adicionar uma lista de Notifica\u00e7\u00f5es \u00e0 sua classe e v\u00e1rios m\u00e9todos para interagir com ela.\n\n## \u27a1\ufe0f Como usar\n\n### \ud83d\udd27 Instala\u00e7\u00e3o\n\n````bash\npip install flunt\n````\n\n### \ud83d\udd14 Notifiable\n\n````python\nfrom flunt.notifications.notifiable import Notifiable\nfrom flunt.validations.contract import Contract\n\nclass Nome(Notifiable):\n def __init__(self, nome):\n super().__init__()\n\n if len(nome) > 3:\n self.add_notification(\n Notification(field='nome', message='nome inv\u00e1lido')\n )\n\n self._nome = nome\n````\n\n### \ud83d\udcdc Contract\n````python\n\"\"\"M\u00f3dulo Objetos de Valor.\"\"\"\nfrom flunt.notifications.notifiable import Notifiable\nfrom flunt.validations.contract import Contract\n\n\nclass Nome(Notifiable):\n \"\"\"Classe Objeto de Valor Nome.\"\"\"\n\n def __init__(self, primeiro_nome, ultimo_nome):\n \"\"\"Encontrar 'Construtor'.\"\"\"\n super().__init__()\n self.primeiro_nome = primeiro_nome\n self.ultimo_nome = ultimo_nome\n self.add_notifications(\n Contract()\n .requires(self.primeiro_nome, 'primeiro nome')\n .requires(self.ultimo_nome, '\u00faltimo nome')\n .is_greater_than(\n value=self.primeiro_nome,\n comparer=3,\n key=\"primeiro_nome\",\n message=\"M\u00ednimo de 3 caracteres\",\n )\n .is_greater_than(\n value=self.ultimo_nome,\n comparer=3,\n key=\"ultimo_nome\",\n message=\"M\u00ednimo de 3 caracteres\",\n )\n .get_notifications()\n )\n\n\nnome = Nome('Emerson', 'Delatorre')\nif not nome.is_valid():\n for notification in nome.get_notifications():\n print(notification)\n\n````\n\n## Contribuindo\n\nConsulte nosso DevGuide no link a seguir: [CONTRIBUTING](https://github.com/fazedordecodigo/PyFlunt/blob/main/README.md/CONTRIBUTING.md)\n\n## Registro de Altera\u00e7\u00f5es\n\nConsulte nosso registro de altera\u00e7\u00f5es no link a seguir: [CHANGELOG](https://github.com/fazedordecodigo/PyFlunt/blob/main/README.md/CHANGELOG.md)\n\n## \ud83d\udcc4 Licen\u00e7a\n\nEste projeto cont\u00e9m a licen\u00e7a MIT. Consulte o arquivo [LICENSE](https://github.com/fazedordecodigo/PyFlunt/blob/main/README.md/LICENSE).\n\n## Mods\n* [Flunt para C# (Original)](https://github.com/andrebaltieri/Flunt)\n* [Flunt.Br](https://github.com/lira92/flunt.br)\n* [Flunt para Java](https://github.com/carlosbritojun/jflunt)\n* [Flunt para JavaScript](https://github.com/jhonesgoncal/flunt)\n* [Flunt para PHP](https://github.com/matheusbloise/flunt-php)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python implementation of Domain Notification Pattern inspired by Flunt (.NET)",
"version": "2.3.0",
"project_urls": {
"Documentation": "https://github.com/Delatorrea/PyFlunt",
"Homepage": "https://github.com/Delatorrea/PyFlunt",
"Repository": "https://github.com/Delatorrea/PyFlunt"
},
"split_keywords": [
"notifications",
"python",
"ddd",
"python3",
"validations",
"notification",
"ddd-patterns",
"ddd-architecture",
"validation-library",
"class-validator",
"fluentvalidation",
"class-validation",
"flunt",
"domain-notification",
"class-validator-cpf"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cb0efcf2826eac4954231ba70b699afbb54971c55f87419b3fbc646b9ed30477",
"md5": "5a785c988d7f522f49969717803018f1",
"sha256": "f1e61b41cc02256d60566684b5c5ccccf7f26fdb0f05e125e128a96bc6fca1d4"
},
"downloads": -1,
"filename": "flunt-2.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5a785c988d7f522f49969717803018f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 18062,
"upload_time": "2024-03-18T02:04:35",
"upload_time_iso_8601": "2024-03-18T02:04:35.805435Z",
"url": "https://files.pythonhosted.org/packages/cb/0e/fcf2826eac4954231ba70b699afbb54971c55f87419b3fbc646b9ed30477/flunt-2.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8bd6910a7281adc5bc17e4d07d8ac8f0617b2131ed61539288dff31a152c09e9",
"md5": "763bfde871caa91ebb4e32b145fe5d2d",
"sha256": "012acc74fdc973b146fe0d4986742de0917a1fddcbfda4ce397a38794586d4e3"
},
"downloads": -1,
"filename": "flunt-2.3.0.tar.gz",
"has_sig": false,
"md5_digest": "763bfde871caa91ebb4e32b145fe5d2d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 13565,
"upload_time": "2024-03-18T02:04:37",
"upload_time_iso_8601": "2024-03-18T02:04:37.091666Z",
"url": "https://files.pythonhosted.org/packages/8b/d6/910a7281adc5bc17e4d07d8ac8f0617b2131ed61539288dff31a152c09e9/flunt-2.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-18 02:04:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Delatorrea",
"github_project": "PyFlunt",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "flunt"
}