File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ pub struct ProposalDocument {
1818}
1919
2020impl ProposalDocument {
21- /// Try to build `ProposalDocument` from `CatalystSignedDoc` collecting report
21+ /// Try to build `ProposalDocument` from `CatalystSignedDoc` doing all necessary
22+ /// stateless verifications,
2223 #[ allow( dead_code) ]
2324 pub ( crate ) fn from_signed_doc (
2425 doc : & CatalystSignedDocument , error_report : & ProblemReport ,
@@ -46,6 +47,13 @@ impl ProposalDocument {
4647 let content = doc. doc_content ( ) . decoded_bytes ( ) . to_vec ( ) ;
4748 Ok ( Self { content } )
4849 }
50+
51+ /// A comprehensive validation of the `ProposalDocument` content.
52+ #[ allow( clippy:: unused_self) ]
53+ pub ( crate ) fn validate_with_report < F > ( & self , _doc_getter : F , _error_report : & ProblemReport )
54+ where F : FnMut ( ) -> Option < CatalystSignedDocument > {
55+ // TODO: implement the rest of the validation
56+ }
4957}
5058
5159impl TryFrom < CatalystSignedDocument > for ProposalDocument {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ use crate::{
1515///
1616/// Returns a report of validation failures and the source error.
1717pub fn validate < F > (
18- doc : & CatalystSignedDocument , _doc_getter : F ,
18+ doc : & CatalystSignedDocument , doc_getter : F ,
1919) -> Result < ( ) , CatalystSignedDocError >
2020where F : FnMut ( ) -> Option < CatalystSignedDocument > {
2121 let error_report = ProblemReport :: new ( "Catalyst Signed Document Validation" ) ;
@@ -39,7 +39,9 @@ where F: FnMut() -> Option<CatalystSignedDocument> {
3939 #[ allow( clippy:: match_same_arms) ]
4040 match doc_type {
4141 DocumentType :: ProposalDocument => {
42- drop ( ProposalDocument :: from_signed_doc ( doc, & error_report) ) ;
42+ if let Ok ( proposal_doc) = ProposalDocument :: from_signed_doc ( doc, & error_report) {
43+ proposal_doc. validate_with_report ( doc_getter, & error_report) ;
44+ }
4345 } ,
4446 DocumentType :: ProposalTemplate => { } ,
4547 DocumentType :: CommentDocument => { } ,
You can’t perform that action at this time.
0 commit comments