The SHACL vocabulary uses prefix sh:
and namespace http://www.w3.org/ns/shacl#
, it is a W3C recommendation.
The Shapes Constraint Language (SHACL) is a validation framework for RDF graphs.
Constraint components can be used both in property shape and node shape definitions unless stated otherwise. Property & node shapes relate to the concept of value nodes which defines the nodes in the data graph in scope relative to the focus node to run a validator constraint using the shapes graph.
Property shapes have 1 sh:path
value and node shapes have none.
sh:class
- Validates instance or subclass of an
rdfs:Class
. Can be checked via the SPARQL property pathrdf:type/rdfs:subClassOf*
. Example possible value:ex:PostalAddress
. sh:datatype
- Validates datatype. Example possible values:
xsd:string
,xsd:boolean
,xsd:decimal
,xsd:integer
,rdf:HTML
or any of the XML Schema Built-in Datatypes. sh:nodeKind
- Validates kind of RDF term: IRI, Literal or Blank node. Can be checked via SPARQL using
FILTER
,isIRI()
,isLiteral()
andisBlank()
. Possible values:sh:IRI
,sh:Literal
,sh:BlankNode
,sh:BlankNodeOrIRI
,sh:BlankNodeOrLiteral
,sh:IRIOrLiteral
.
sh:minCount
- Validates minimum cardinality of property path. Minimum cardinality of 0 is always satisfied. Possible values: literals with datatype
xsd:integer
. sh:maxCount
- Validates maximum cardinality of property path. Possible values: literals with datatype
xsd:integer
.
Validate value nodes that are comparable via the >
, >=
, <
and <=
operators (numeric values).
sh:minExclusive
- Validates minimum exclusive value of a literal node. Can be checked via SPARQL using:
FILTER ($value > $minExclusive)
. Possible values:0
,-32
,43.7
. sh:minInclusive
- Validates minimum inclusive value of a literal node. Can be checked via SPARQL using:
FILTER ($value >= $minInclusive)
. Possible values:0
,-32
,43.7
. sh:maxExclusive
- Validates maximum exclusive value of a literal node. Can be checked via SPARQL using:
FILTER ($value < $maxExclusive)
. Possible values:0
,-32
,43.7
. sh:maxInclusive
- Validates maximum inclusive value of a literal node. Can be checked via SPARQL using:
FILTER ($value <= $maxInclusive)
. Possible values:0
,-32
,43.7
.
Validate strings.
sh:minLength
- Validates minimum string length. Can be checked via SPARQL using:
FILTER (STRLEN(str($value)) >= $minLength)
. Possible values: literals with datatypexsd:integer
. sh:maxLength
- Validates maximum string length. Can be checked via SPARQL using:
FILTER (STRLEN(str($value)) <= $maxLength)
. Possible values: literals with datatypexsd:integer
. sh:pattern
- Validates string against a regular expression. Can be checked via SPARQL using:
FILTER (!isBlank($value) && IF(bound($flags), regex(str($value), $pattern, $flags), regex(str($value), $pattern)))
. Possible values: see XPath and XQuery regular expression syntax and regular expression flags. sh:languageIn
- Validates literal language tags. Example value:
sh:property [ sh:path ex:prefLabel ; sh:languageIn ( "en" "mi" ); ]
(values ofex:prefLabel
can be either in English or Māori). sh:uniqueLang
- Validates no pair of value nodes use the same language tag. Possible value:
true
.