Skip to main content

linked_data_schema/linked_data_schema_field_visitor/
uuid.rs

1use crate::LinkedDataSchemaFieldVisitor;
2use iri_s::iri;
3use prefixmap::IriRef;
4use shacl::ast::ASTComponent;
5
6impl LinkedDataSchemaFieldVisitor for ::uuid::Uuid {
7  fn field_components() -> Vec<ASTComponent> {
8    vec![
9      ASTComponent::MinCount(1),
10      ASTComponent::MaxCount(1),
11      ASTComponent::Datatype(Self::type_iri_ref().unwrap()),
12      ASTComponent::Pattern {
13        pattern:
14          "/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i"
15            .to_string(),
16        flags: None,
17      },
18    ]
19  }
20
21  fn type_iri_ref() -> Option<IriRef> {
22    Some(IriRef::iri(iri!("xsd::string")))
23  }
24}