Dash Core  0.12.2.1
P2P Digital Currency
governance-validators.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2017 The Dash Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef GOVERNANCE_VALIDATORS_H
6 #define GOVERNANCE_VALIDATORS_H
7 
8 #include <string>
9 
10 #include <univalue.h>
11 
13 public:
14  CProposalValidator(const std::string& strDataHexIn = std::string());
15 
16  void Clear();
17 
18  void SetHexData(const std::string& strDataHexIn);
19 
20  bool Validate();
21 
22  bool ValidateJSON();
23 
24  bool ValidateName();
25 
26  bool ValidateStartEndEpoch();
27 
28  bool ValidatePaymentAmount();
29 
31 
32  bool ValidateURL();
33 
34  const std::string& GetErrorMessages()
35  {
36  return strErrorMessages;
37  }
38 
39 private:
40  void ParseJSONData();
41 
42  bool GetDataValue(const std::string& strKey, std::string& strValue);
43 
44  bool GetDataValue(const std::string& strKey, int64_t& nValue);
45 
46  bool GetDataValue(const std::string& strKey, double& dValue);
47 
48  static std::string StripWhitespace(const std::string& strIn);
49 
50  static bool CheckURL(const std::string& strURLIn);
51 
52 private:
53  std::string strData;
54 
56 
57  bool fJSONValid;
58 
59  std::string strErrorMessages;
60 
61 };
62 
63 #endif
const std::string & GetErrorMessages()
static std::string StripWhitespace(const std::string &strIn)
static bool CheckURL(const std::string &strURLIn)
void SetHexData(const std::string &strDataHexIn)
bool GetDataValue(const std::string &strKey, std::string &strValue)
CProposalValidator(const std::string &strDataHexIn=std::string())