Type-safe and generic implementation of the build pattern in Typescript
How to use it
- No methods in class
- No need to keep properties private and controlling object manipulation
// Usage of the Builder.with.with.with.build;// Optional implementation of the Validatable interface. Builder calls validate() *BEFORE* an object is build.
Usage in the context of Domain Driven Design
- Use cases:
- Model is implemented in domain driven fassion, that is class contains methods which are encapsulating business logic
- Property access is kept private to enforce object manipulation through business logic methods
// Usage of the DomainBuilder.with.with.with.build;// Model definition
Implementation of Validatable interface
Implement the Validatable interface if you want to run validations before the builder creates the object.