Skip to content

Commit 6ad5b81

Browse files
committed
chore(rust/signed-doc): cleanup report messages
1 parent b6b536c commit 6ad5b81

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

rust/signed_doc/src/validator/rules/ownership/mod.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ use catalyst_types::catalyst_id::CatalystId;
99

1010
use crate::{providers::CatalystSignedDocumentProvider, CatalystSignedDocument};
1111

12+
/// Context for the validation problem report.
13+
const REPORT_CONTEXT: &str = "Document ownership validation";
14+
1215
/// Returns `true` if the document has a single author.
1316
///
1417
/// If not, it adds to the document's problem report.
1518
fn single_author_check(doc: &CatalystSignedDocument) -> bool {
1619
let is_valid = doc.authors().len() == 1;
1720
if !is_valid {
1821
doc.report().functional_validation(
19-
"New document must only be signed by a single author",
20-
"Valid documents must only be signed by the original author",
22+
"Document must only be signed by one author",
23+
REPORT_CONTEXT,
2124
);
2225
}
2326
is_valid
@@ -80,8 +83,8 @@ impl DocumentOwnershipRule {
8083

8184
if !is_valid {
8285
doc.report().functional_validation(
83-
"New document must only be signed by a single author or collaborators defined in the previous version",
84-
"Valid documents must only be signed by the original author or known collaborators",
86+
"Document must only be signed by original author and/or by collaborators defined in the previous version",
87+
REPORT_CONTEXT,
8588
);
8689
}
8790
return Ok(is_valid);
@@ -97,8 +100,8 @@ impl DocumentOwnershipRule {
97100
let is_valid = first_doc.authors() == doc.authors();
98101
if !is_valid {
99102
doc.report().functional_validation(
100-
&format!("New document authors must match the authors from the first version for Document ID {doc_id}"),
101-
"Valid documents must only be signed by the original author",
103+
"Document authors must match the author from the first version",
104+
REPORT_CONTEXT,
102105
);
103106
}
104107
return Ok(is_valid);

rust/signed_doc/src/validator/rules/ownership/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn gen_original_doc_and_provider(
103103
let (doc_1, _, _, _, provider) = gen_original_doc_and_provider(ONE_AUTHOR,NO_COLLABS);
104104
(doc_1, provider)
105105
} => true ;
106-
"First Version Catalyst Signed Document has the only one author"
106+
"First Version Catalyst Signed Document has only one author"
107107
)]
108108
#[test_case(
109109
|| {
@@ -188,7 +188,7 @@ async fn simple_author_rule_test(
188188
let doc= gen_next_ver_doc(doc_id, other_authors, collabs);
189189
(doc, provider)
190190
} => false ;
191-
"Latest Catalyst Signed Document has the unexpected authors"
191+
"Latest Catalyst Signed Document signed by unexpected author"
192192
)]
193193
#[tokio::test]
194194
async fn author_with_collaborators_rule_test(

0 commit comments

Comments
 (0)