Solutions
67. Validating passwords
The problem described here is a typical case for the decorator pattern. This design pattern allows adding behavior to an object without affecting other objects of the same type. This is achieved by wrapping an object within another object. Multiple decorators could be stacked on top of each other, each time adding new functionality. In our case, the functionality would be validating that a given password meets a particular requirement.
The following class diagram describes the pattern for validating passwords:
The implementation of the pattern, as described in the diagram, is as follows:
class password_validator
{
public:
virtual bool validate(std::string_view password) = 0;
virtual ~password_validator...