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:
| Profile | Behaviour |
| default | Every rule runs; warnings are recorded but are not fatal. |
| strict | Every rule runs; warnings are fatal, so a report with warnings fails alongside reports with errors. |
| publication | Every 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_styleA 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"
endThe 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.