#ifndef COMDEL_VALIDATOR_H #define COMDEL_VALIDATOR_H #include "instance.h" #include "schema.h" namespace domain { struct ValidationError { ComponentInstance *instance; InstanceAttribute *attribute; Action::ActionType type; std::string message; }; struct ValidationContext { ComponentInstance *instance; InstanceAttribute *attribute; std::map addressSpaces; std::map attributes; }; class ComdelValidator { public: std::vector validateSchema(Schema& schema, ValidationContext context); std::vector validateComponent(ComponentInstance *instance, ValidationContext context); std::vector validateAttribute(InstanceAttribute *attribute, ValidationContext context); std::optional validateRule(Rule rule, ValidationContext context); ComdelValidator(std::vector validators) { for(auto* validator: validators) { validator->clear(); this->validators.insert(std::make_pair(validator->getName(), validator)); } } private: std::map validators; std::string populateMessage(string message, ValidationContext context); string replacePlaceholder(string message, const string name, Value value); }; } #endif //COMDEL_VALIDATOR_H