Skip to content
Metanorma
On this page

Validation profiles and document-type exemptions

Metanorma for ISO validates a document against the ISO/IEC Directives, Part 2 and the ISO House Style, and reports every violation with a stable rule code such as ISO_29 or ISO_63. The validation rule catalog lists every code with its severity and category, and is generated from the metanorma-iso source so it cannot drift from the code. This page documents the machinery that decides which rules run: the validation profiles, and the document-type exemption that keeps amendment documents free of full-standard structure findings.

Rules and profiles

Every rule is a Ruby class that declares its log key with code "ISO_N", its policy documentation with a policy declaration, and returns findings from its check. The registry discovers every concrete rule class in the metanorma-iso gem automatically, so a new rule file is the whole registration. The orchestrator runs the discovered rules against the deserialized document model and records the findings in the build log and the validation report.

A profile filters which rules run and configures how warnings are treated. Three built-in profiles cover the common cases:

ProfileBehaviour
defaultEvery rule runs; warnings are recorded but are not fatal.
strictEvery rule runs; warnings are fatal, so a report with warnings fails alongside reports with errors.
publicationEvery rule runs except the style-warning family (the House Style text lints), for documents whose style findings have already been addressed.

A custom profile selects rules by code. only_codes keeps just the named rules, and except_codes drops the named ones:

profile = Metanorma::Iso::Validation::Profile.new(
  name: "ci",
  only_codes: ["ISO_5", "ISO_29", "ISO_30", "ISO_31"],
  strict_warnings: true
)
Metanorma::Iso.validate(xml, profile: profile)

Published profiles

Declarative profile files ship with the metanorma-iso gem under lib/metanorma/iso/validation/profiles/ — for example house-style.yml, quality-english.yml and oxford-spelling.yml. Each file declares the metanorma-validation-profile/1 schema and a select: block whose entries pick rules by policy metadata (mn_category, source or category) or directly by rule class name. Entries are disjunctive; the keys inside one entry are conjunctive.

schema: metanorma-validation-profile/1
profile: house-style-core
flavor: iso
select:
  - mn_category: style
    source: house_style

A published profile is loaded by name with Profile.load, and an unknown name or an unrecognized schema aborts the load, so an importer pins behavior instead of drifting:

profile = Metanorma::Iso::Validation::Profile.load("house-style-core")
Metanorma::Iso.validate(xml, profile: profile)

The amendment document-type exemption

Some rules enforce the full-standard structure contract: the section sequencing (ISO_28), the Scope clause (ISO_29), the Normative references clause (ISO_30), the Terms and definitions clause (ISO_31) and the subclause-free Scope (ISO_39). Amendments and technical corrigenda are not freestanding standards and legitimately lack these elements; running the structure contract against them produces false positives.

Such rules declare the doctypes they do not apply to with the exempt_doctypes declaration on the rule class:

class ScopePresenceRule < Base
  code "ISO_29"
  policy category: "Document structure",
         rule: "the document must contain a Scope clause",
         source: :directives, directives: "14.3",
         mn_category: :structure
  exempt_doctypes "amendment", "technical-corrigendum"
end

The validator enforces the declaration when it runs the rules: a rule whose declared list contains the document's doctype is skipped for that document. The doctype is the document's own declaration — an amendment compiled with :doctype: amendment skips the structure contract, while an international standard still runs every rule. A declaration accumulates across calls, and a document without a doctype exempts nothing.

The declaration is kept honest by an audit specification in the metanorma-iso gem: every rule whose policy category is "Document structure" must declare the amendment exemption, so a future structure rule without the declaration fails continuous integration. The exemptions therefore stay a recorded decision rather than an accidental omission.

What a document author needs to know

The profile and exemption machinery needs no document attributes. An amendment document is declared the usual way, and the structure findings are skipped for it automatically; all remaining rules — style, titles, cross-references — still run. Suppression of individual rule codes, where a check does not fit a particular document, is a separate mechanism and is documented on the content validation page.

Edit this page on GitHub →