shacl_ir/components/max_lenght.rs
1use std::fmt::Display;
2
3/// sh:maxLength specifies the maximum string length of each value node that
4/// satisfies the condition. This can be applied to any literals and IRIs, but
5/// not to blank nodes.
6///
7/// https://www.w3.org/TR/shacl/#MaxLengthConstraintComponent
8#[derive(Debug, Clone)]
9pub struct MaxLength {
10 max_length: isize,
11}
12
13impl MaxLength {
14 pub fn new(max_length: isize) -> Self {
15 MaxLength { max_length }
16 }
17
18 pub fn max_length(&self) -> isize {
19 self.max_length
20 }
21}
22
23impl Display for MaxLength {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 write!(f, "MaxLength: {}", self.max_length())
26 }
27}