30 lines
759 B
C++
30 lines
759 B
C++
|
#include "anypolicyvalidator.h"
|
||
|
#include "policy.h"
|
||
|
|
||
|
AnyPolicyValidator::AnyPolicyValidator(const std::list<std::shared_ptr<Policy>>& policies) :
|
||
|
Validator(policies)
|
||
|
{}
|
||
|
|
||
|
AnyPolicyValidator::~AnyPolicyValidator()
|
||
|
{}
|
||
|
|
||
|
Validator::ValidateResult AnyPolicyValidator::validate(const std::shared_ptr<Actor> &actor) const
|
||
|
{
|
||
|
Validator::ValidateResult validate_result{false, ""};
|
||
|
|
||
|
for (const auto& policy : _validation_policies)
|
||
|
{
|
||
|
const auto result = policy->check(actor);
|
||
|
|
||
|
if (result.satisfied)
|
||
|
{
|
||
|
validate_result.validate_output += result.commentary;
|
||
|
validate_result.validate_output += "\n\n";
|
||
|
validate_result.success = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return validate_result;
|
||
|
}
|