summaryrefslogtreecommitdiff
path: root/chromium/components/policy/core/common/cloud/policy_value_validator.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/policy/core/common/cloud/policy_value_validator.h')
-rw-r--r--chromium/components/policy/core/common/cloud/policy_value_validator.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/chromium/components/policy/core/common/cloud/policy_value_validator.h b/chromium/components/policy/core/common/cloud/policy_value_validator.h
new file mode 100644
index 00000000000..166cc257db0
--- /dev/null
+++ b/chromium/components/policy/core/common/cloud/policy_value_validator.h
@@ -0,0 +1,41 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_POLICY_VALUE_VALIDATOR_H_
+#define COMPONENTS_POLICY_CORE_COMMON_CLOUD_POLICY_VALUE_VALIDATOR_H_
+
+#include <string>
+
+namespace policy {
+
+struct ValueValidationIssue {
+ enum Severity { kWarning, kError };
+
+ std::string policy_name;
+ Severity severity = kWarning;
+ std::string message;
+
+ bool operator==(ValueValidationIssue const& rhs) const {
+ return policy_name == rhs.policy_name && severity == rhs.severity &&
+ message == rhs.message;
+ }
+};
+
+template <typename PayloadProto>
+class PolicyValueValidator {
+ public:
+ PolicyValueValidator() = default;
+ PolicyValueValidator(const PolicyValueValidator&) = delete;
+ PolicyValueValidator& operator=(const PolicyValueValidator&) = delete;
+ virtual ~PolicyValueValidator() = default;
+
+ // Returns false if the value validation failed with errors.
+ virtual bool ValidateValues(
+ const PayloadProto& policy_payload,
+ std::vector<ValueValidationIssue>* out_validation_issues) const = 0;
+};
+
+} // namespace policy
+
+#endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_POLICY_VALUE_VALIDATOR_H_