Message grammar#
Message grammar describes declared user-facing messages, severities, parameters, localization blocks, and message catalogs.
Source#
| Property | Value |
|---|---|
| Grammar file | packages/business/language/grammar/message.g4 |
| Grammar name | message |
| Grammar kind | parser |
| Imports | common, type, literal |
| Imported by | BusinessLanguage, module |
| Direct rule or token count | 33 |
How to use this page#
Read the examples first when authoring Business Language. Use the rule inventory when checking exact grammar coverage or when updating parser, lowering, editor, or documentation behavior.
Entry rules and syntax families#
Start with these rules when reading this grammar: messageDeclaration, categoryType, messagePluralBody, labelDeclaration.
- Declarations:
labelDeclaration,messageDeclaration - Types:
categoryType - Bodies:
messagePluralBody
Key grammar excerpts#
messageDeclaration#
messageDeclaration: annotation* accessModifier? MESSAGE identifier OPEN_BRACE messageMemberList? CLOSE_BRACE
// @define @name_fields(identifier) @symbol(kind=global) @scope(level=2)
;categoryType#
categoryType: VALIDATION | RULE | SECURITY | INTEGRITY | IO | PERFORMANCE | DOMAIN | SYSTEM | USER | INFO | CUSTOM OPEN_PAREN stringLiteral CLOSE_PAREN;messagePluralBody#
messagePluralBody: messagePluralLocale messagePluralLocale*;Complete rule and token inventory#
categoryType, labelAnnotation, labelContent, labelDeclaration, labelMember, labelMemberList, languageCode, localizationBlock
localizedContent, localizedEntry, localizedEntryList, messageAnnotation, messageContent, messageDeclaration, messageEntityReference, messageHeaderProperty
messageHeaderValue, messageMember, messageMemberList, messageMetadata, messageMetadataProperty, messageMetadataPropertyList, messageMetadataValue, messageParams
messagePlural, messagePluralBody, messagePluralForm, messagePluralLocale, messagePriority, parameterBlock, parameterDefinition, parameterDefinitionList
severityLevelExamples#
Parameterized message#
message MissingApprovalPolicy {
severity: error;
category: validation;
message: {
en: "No approval policy exists for company {company_code}.";
};
params: {
company_code: CompanyCode;
};
}Localized message block#
message DuplicateInvoice {
severity: error;
message: {
en: "Invoice {invoice_number} already exists.";
ar: "Invoice {invoice_number} already exists.";
};
params: {
invoice_number: string;
};
}Metadata, entity, and plural forms#
message InvoiceLineCountInvalid {
code: "AP-ERR-0300";
severity: error;
category: custom("policy");
entity Invoice;
params: {
line_count: int;
};
metadata: {
owner: "payables";
tags: ["invoice", "validation"];
priority: high;
};
plural lines: line_count {
en: {
one: "Invoice must contain one line.";
other: "Invoice must contain multiple lines.";
};
};
message: {
en: "Invoice line count is invalid.";
};
}Common authoring mistakes#
- Do not raise inline string errors from executable logic.
- Declare parameters explicitly so callers and translators know which values can appear in user-facing text.
Related guides#
- /language/messages-errors/
- /language/rules-tests-errors/
Authoring notes#
- Keep examples aligned with the grammar source, not with inferred syntax from another language.
- Use declared messages for user-facing failures, and fail closed when required configuration is absent.