Controls

Description

Controls encapsulate the logic necessary to identify whether or not a specific action or mutation is acceptable. You can think of our controls as model validations that require more context than our models are allowed to encapsulate.

Models may delegate validation to controls.

Controls should not mutate data under any circumstances.

Controls should serve as a centralized place where we can check the criteria that must be met in order for a certain action or mutation to be permissible.

Controls have been most useful for us when encapsulating complex checks/guards for validating object and guarding against allowing actions in the system. For example, checking if a loan is disbursable requires several different checks and is a good example of a useful control. Controls are also a good way to share/reuse this complex logic. Controls should not be used for simple guards/predicates.

Technology Status at Wunder

Adopt. Controls are a useful tool to encapsulate complex logic around validations or guards against performing certain actions in the system.

Notes/Resources