/pyflunt

:wolf: Python implementation of Domain Notification Pattern based in Flunt(.NET), JFlunt(Java) developed by @andrebaltieri, @carlosbritojun

Primary LanguagePythonMIT LicenseMIT

Pyflunt

Project   |    Techs   |    How to use   |    License

🚀 Project

🐺 Python implementation of Domain Notification Pattern based in Flunt(.NET), JFlunt(Java) developed by @andrebaltieri, @carlosbritojun

💻 Techs

🤔 How to use

Installation

pip install pyflunt

Notifiable

from pyflunt.notifications import Notifiable, Notification

class Name(Notifiable):
    def __init__(self, name):
        super().__init__()
        
        if len(name) > 3:
            self.add_notification(Notification(field='name', message='invalid name'))

        self._name = name

Contract

from pyflunt.notifications import Notifiable
from pyflunt.validations import Contract

class Email(Notifiable):
    def __init__(self, email):
        super().__init__()

        self._email = email

        contract = (Contract().requires()
                              .has_max_len(value=email,
                                           maximum=50,
                                           message='invalid email')
                              .is_email(value=email,
                                        field='email',
                                        message='invalid email'))

        self.add_notifications(contract)

📝 License

This project contains the MIT license. See the file LICENSE.