Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Copyright (c) 2024 Muhammad Nawaz |
3 |
|
|
* Licensed under the MIT License. See LICENSE file for more information. |
4 |
|
|
*/ |
5 |
|
|
// [ END OF LICENSE c6bd0f49d040fca8d8a9cb05868e66aa63f0e2e0 ] |
6 |
|
|
|
7 |
|
|
#ifndef VALIDATOR_HPP |
8 |
|
|
#define VALIDATOR_HPP |
9 |
|
|
|
10 |
|
|
#include "utils/common.hpp" |
11 |
|
|
|
12 |
|
|
#include <string> |
13 |
|
|
#include <unordered_map> |
14 |
|
|
|
15 |
|
|
class BaseValidator |
16 |
|
|
{ |
17 |
|
|
public: |
18 |
|
|
explicit BaseValidator(ValidationError err_code); |
19 |
|
|
explicit BaseValidator(const std::vector<std::string>& ref_keys, ValidationError err_code); |
20 |
|
|
|
21 |
|
|
virtual ValidationError Validate(const std::string& content, std::string& err_msg) = 0; |
22 |
|
|
std::string GetErrHeader() const; |
23 |
|
1092 |
virtual ~BaseValidator() = default; |
24 |
|
|
|
25 |
|
|
protected: |
26 |
|
|
ValidationError code_on_error_; |
27 |
|
|
std::string err_header_; |
28 |
|
|
|
29 |
|
|
private: |
30 |
|
|
static const std::unordered_map<ValidationError, std::string> kErrHeaders; |
31 |
|
|
}; |
32 |
|
|
|
33 |
|
|
#endif // VALIDATOR_HPP |
34 |
|
|
|