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

input-output-hk / catalyst-libs / 17261071422

27 Aug 2025 08:09AM UTC coverage: 66.962% (+0.01%) from 66.948%
17261071422

Pull #497

github

web-flow
Merge 94dfdf398 into 74fefc0f1
Pull Request #497: refactor(rust/signed-doc): Move `validate_id_and_ver` as separate rules `IdRule` and `VerRule`

88 of 111 new or added lines in 4 files covered. (79.28%)

3 existing lines in 1 file now uncovered.

12623 of 18851 relevant lines covered (66.96%)

2799.35 hits per line

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

66.67
/rust/signed_doc/src/validator/rules/ver.rs
1
//! Validator for Signed Document Version
2

3
use crate::CatalystSignedDocument;
4

5
/// Signed Document `ver` field validation rule
6
pub(crate) struct VerRule;
7

8
impl VerRule {
9
    /// Validates document `ver` field on the timestamps:
10
    /// 1. document `ver` cannot be smaller than document `id` field
11
    #[allow(clippy::unused_async)]
12
    pub(crate) async fn check(
18✔
13
        &self,
18✔
14
        doc: &CatalystSignedDocument,
18✔
15
    ) -> anyhow::Result<bool> {
18✔
16
        let Ok(id) = doc.doc_id() else {
18✔
NEW
17
            doc.report().missing_field(
×
NEW
18
                "id",
×
NEW
19
                "Cannot get the document field during the field validation",
×
20
            );
NEW
21
            return Ok(false);
×
22
        };
23
        let Ok(ver) = doc.doc_ver() else {
18✔
NEW
24
            doc.report().missing_field(
×
NEW
25
                "ver",
×
NEW
26
                "Cannot get the document field during the field validation",
×
27
            );
NEW
28
            return Ok(false);
×
29
        };
30

31
        if ver < id {
18✔
32
            doc.report().invalid_value(
1✔
33
                "ver",
1✔
34
                &ver.to_string(),
1✔
35
                "ver < id",
1✔
36
                &format!("Document Version {ver} cannot be smaller than Document ID {id}"),
1✔
37
            );
38
            return Ok(false);
1✔
39
        }
17✔
40

41
        Ok(true)
17✔
42
    }
18✔
43
}
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

© 2025 Coveralls, Inc