This tutorial shows you how to extend the validations capabilities of AML-defined metadata by writing custom validations that can be enforced by AMF.
- JVM: version 7 or higher
- SBT to build the AMF command-line
You can download the example from the AML project examples repository in Github.
This tutorial assumes you have a working version of the AMF command-line as described in the quickstart tutorial.
AML Dialects encode a mapping from the AST of a YAML/JSON document to a metadata graph and a set of constraints over the shape of that graph. These constraints are formally defined in the AML specification using a W3C recommendation known as SHACL.
AMF or any other SHACL compliant processor can validate the graph of data parsed from an AML document using the set of SHACL constraints parsed from the associated AML Dialect.
The AML Dialect
Playlist 1.0 located at
aml/examples/music/dialect/playlist.yaml defines a metadata document to encode musical playlists:
The dialect provides the semantics of the metadata using two AML Vocabularies for music and music curation, located at
Using this dialect, we can describe document instances encoding playlist information like the one located in
AMF can be used to validate any AML document instance using the
Additional validation constraints can be defined over the parsed graph of metadata using a validation profile.
Validation profiles are documents defined after describing an AML Dialect for validation profiles.
An example of a validation profile can be found at
aml/music/custom_validations/boring.yaml. This profile adds validation errors for every single song with a duration longer than 180 seconds:
As an example, the constraint has been declared in two different ways.
too-long1 defines the constraint declaratively, using the syntax defined in the
Validation Profile dialect.
Both constraints target nodes in the parsed graph, using the semantics defined in the
Music AML Vocabulary: the class
music.Track and the property
This validation profile can be used in the AMF command line tool using the