• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / catalyst-libs / 17492614421

05 Sep 2025 12:05PM UTC coverage: 68.54%. First build
17492614421

Pull #540

github

web-flow
Merge 01b62b8a2 into 90c3a5070
Pull Request #540: feat(rust/signed-doc): Split into two `ContentRule` and `TemplateRule`

407 of 421 new or added lines in 5 files covered. (96.67%)

13525 of 19733 relevant lines covered (68.54%)

3002.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.57
/rust/signed_doc/src/validator/rules/utils.rs
1
//! utility functions for validation rules
2

3
use std::fmt::Write;
4

5
use crate::{validator::json_schema::JsonSchema, CatalystSignedDocument};
6

7
/// Validating the document's content against the provided JSON schema
8
pub(crate) fn content_json_schema_check(
18✔
9
    doc: &CatalystSignedDocument,
18✔
10
    schema: &JsonSchema,
18✔
11
) -> bool {
18✔
12
    const CONTEXT: &str = "Document content JSON schema validation";
13

14
    let Ok(doc_content) = doc.decoded_content() else {
18✔
NEW
15
        doc.report().functional_validation(
×
NEW
16
            "Invalid Document content, cannot get decoded bytes",
×
NEW
17
            CONTEXT,
×
18
        );
NEW
19
        return false;
×
20
    };
21
    if doc_content.is_empty() {
18✔
22
        doc.report()
2✔
23
            .missing_field("payload", "Document must have a content");
2✔
24
        return false;
2✔
25
    }
16✔
26
    let Ok(doc_json) = serde_json::from_slice(&doc_content) else {
16✔
27
        doc.report()
2✔
28
            .functional_validation("Document content must be json encoded", CONTEXT);
2✔
29
        return false;
2✔
30
    };
31

32
    let schema_validation_errors =
14✔
33
        schema
14✔
34
            .iter_errors(&doc_json)
14✔
35
            .fold(String::new(), |mut str, e| {
14✔
36
                let _ = write!(str, "{{ {e} }}, ");
1✔
37
                str
1✔
38
            });
1✔
39

40
    if !schema_validation_errors.is_empty() {
14✔
41
        doc.report().functional_validation(
1✔
42
            &format!(
1✔
43
                "Proposal document content does not compliant with the json schema. [{schema_validation_errors}]"
1✔
44
            ),
1✔
45
            CONTEXT,
1✔
46
        );
47
        return false;
1✔
48
    }
13✔
49

50
    true
13✔
51
}
18✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc