Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #ifndef IROHA_PROPOSAL_VALIDATOR_HPP
7 : #define IROHA_PROPOSAL_VALIDATOR_HPP
8 :
9 : #include <boost/format.hpp>
10 : #include <regex>
11 : #include "datetime/time.hpp"
12 : #include "interfaces/common_objects/types.hpp"
13 : #include "interfaces/iroha_internal/proposal.hpp"
14 : #include "validators/abstract_validator.hpp"
15 : #include "validators/answer.hpp"
16 : #include "validators/container_validator.hpp"
17 :
18 : // TODO 22/01/2018 x3medima17: write stateless validator IR-836
19 :
20 : namespace shared_model {
21 : namespace validation {
22 :
23 : /**
24 : * Class that validates proposal
25 : */
26 : template <typename FieldValidator, typename TransactionsCollectionValidator>
27 : class ProposalValidator
28 : : public ContainerValidator<interface::Proposal,
29 : FieldValidator,
30 : TransactionsCollectionValidator>,
31 : public AbstractValidator<interface::Proposal> {
32 : public:
33 : using ContainerValidator<
34 : interface::Proposal,
35 : FieldValidator,
36 : TransactionsCollectionValidator>::ContainerValidator;
37 : /**
38 : * Applies validation on proposal
39 : * @param proposal
40 : * @return Answer containing found error if any
41 : */
42 : Answer validate(const interface::Proposal &prop) const {
43 1328 : return ContainerValidator<
44 : interface::Proposal,
45 : FieldValidator,
46 1328 : TransactionsCollectionValidator>::validate(prop, "Proposal");
47 0 : }
48 : };
49 :
50 : } // namespace validation
51 : } // namespace shared_model
52 :
53 : #endif // IROHA_PROPOSAL_VALIDATOR_HPP
|