Object-Oriented Programming · ByteDance · Medium
Implement an OrderValidator that checks orders against a collection of validation rules, where the set of rules can change over time. The validator must support the following behavior: An order is rejected if it contains any prohibited item, or if a price falls outside the permitted range. Rules can be added to the validator and removed from it. Rules may have prerequisites. These prerequisite relationships form a directed acyclic graph (DAG), and validation must honor them:…