-
Notifications
You must be signed in to change notification settings - Fork 162
Home
Every app has business rules and validations, and you probably will need to keep all the errors and notifications that happened and send it to somewhere, maybe to your UI.
Flunt implements the Notification Pattern and helps you to track everything that happend, consolidating your notifications and making it easy to access and manipulate.
There are a few things you can do with Flunt, let's check them. Remember you can find samples on this wiki!
Do you want to keep track of everything that happened on your classes? Simple! Just inherit from Notifiable class and you'll be able to AddNotifications and check if your class Isvalid.
Every time you add a condition (IF) to your code, you increase it's complexity, and if we take a look, there are a few conditions we could avoid, conditions that check if string is empty for example. So why don't we move it to a function, test it and re-use it? That is what we did!
You can use the Contract class to specifify that some property is required, has a max len, or even to compare values. If any specification of your contract fails, it will automatically add a notification to your class.
Please check the Validations Wiki to see which validations you can apply.
Don't want to mess your code with stupid but necessary validations? Just create specifications. With this, you can specify which validations are necessary to create a new customer for example, to edit an order, and goes on.
Please, check Specifications Wiki for more details and examples.