2.6 File Validation
2.6 File Validation
The structure of a RUML file is defined by the JSON Schema
ruml.schema.json
(draft 2020-12).
When Loading a RUML File, the Following MUST Be Performed:
- Format check:
$formatMUST be “RUML” (Rule FMT-03FMT-03$formatMUST be"RUML".)$specVersionMUST be a supported version (Rule FMT-04FMT-04$specVersionMUST be one of the versions listed in theenumof$specVersionin the schema.,Rule FMT-09FMT-09 A parser MUST accept a file whose$specVersionhas its own MAJOR version and a MINOR version up to its own, and MUST reject a file with a higher MINOR version or a different MAJOR version.)
- Structure check:
- All required fields MUST be present
- Data types MUST conform to the specifications in Chapter 3.2 (
Rule FMT-13FMT-13 Every field value MUST have the data type 3.2.3 gives it: aNumbera JSON number, aBooleana JSON Boolean, aDateTimean RFC 3339date-time, anEnumone of the values defined for the field, anObjecta JSON object, anArraya JSON array.)
- Hash verification (only when using the container format):
- Hash verification is performed at container level (see Chapter 7)
- If a hash is present, it MUST be verified; if there is a mismatch, processing MUST be refused
Identifier check:
- LexIDs MUST be unique; a reused modular node still has exactly one
nodesentry (Rule FMT-12FMT-12 A LexID MUST NOT occur more than once as a key ofrulemap.nodes.) - UUIDs MUST match the pattern (
Rule FMT-10FMT-10 Every UUID MUST be a lowercase UUID version 4 (pattern in 2.5).) - The
nodesobject MUST contain an entry with key"1"(root node) (Rule FMT-08FMT-08rulemap.nodesMUST contain an entry with key"1", the root node.)
Validation of RUML-EXT Files
When loading a RUML-EXT file (.ruml-ext, $format: "RUML-EXT"), a validator MUST additionally
check:
- Referential integrity of
$base: The$base.idMUST match themetadata.idof the referenced base RUML file, and$base.hashMUST match the current hash of the base file (Rule CAP-24CAP-24 Before a merge, the$base.idof a RUML-EXT file MUST equal themetadata.idof the base file, and its$base.hashthe hash of the base file's canonical form; otherwise the parser MUST abort the merge. Each RUML-EXT file is checked on its own.). - UUID existence: Every UUID in the
nodesobject of the EXT file MUST exist in the base RUML file. UUIDs without corresponding nodes in the base file MUST be treated as errors (Rule CAP-26CAP-26 Every node UUID in thenodesof a RUML-EXT file MUST be theidof a node of the base file.).
See Chapter 4.5 for the complete RUML-EXT specification.