shacl_ir/components/min_count.rs
1use std::fmt::Display;
2
3/// sh:minCount specifies the minimum number of value nodes that satisfy the
4/// condition. If the minimum cardinality value is 0 then this constraint is
5/// always satisfied and so may be omitted.
6///
7/// - IRI: https://www.w3.org/TR/shacl/#MinCountConstraintComponent
8/// - DEF: If the number of value nodes is less than $minCount, there is a
9/// validation result.
10#[derive(Debug, Clone)]
11pub struct MinCount {
12 min_count: usize,
13}
14
15impl MinCount {
16 pub fn new(min_count: isize) -> Self {
17 MinCount {
18 min_count: min_count as usize,
19 }
20 }
21
22 pub fn min_count(&self) -> usize {
23 self.min_count
24 }
25}
26
27impl Display for MinCount {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 write!(f, "MinCount: {}", self.min_count())
30 }
31}