Defining custom SHACL shapes (validation)
SHACL (Shapes Constraint Language) files are stored in your configured shapes/ directory. They validate that your page frontmatter is structurally correct.
To create a custom constraint for a class (e.g., a Project class):
- Create a file named
shapes/project-shape.ttl. - Define a
sh:NodeShapethat targets your class and specifies property constraints:
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <https://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix wiki: <https://wazootech.github.io/wiki/wiki/> .
schema:ProjectShape a sh:NodeShape ;
sh:targetClass schema:Project ;
# Required properties
sh:property [
sh:path schema:name ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:datatype xsd:string ;
sh:message "Project must have exactly one name string." ;
] ;
sh:property [
sh:path schema:startDate ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:datatype xsd:date ;
sh:message "Project must have a startDate in YYYY-MM-DD format." ;
] .
When you run wiki check, any page with type: Project is automatically validated against these constraints!