N NezamDocumentation

Message grammar#

Message grammar describes declared user-facing messages, severities, parameters, localization blocks, and message catalogs.

Source#

PropertyValue
Grammar filepackages/business/language/grammar/message.g4
Grammar namemessage
Grammar kindparser
Importscommon, type, literal
Imported byBusinessLanguage, module
Direct rule or token count33

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#

antlr
messageDeclaration: annotation* accessModifier? MESSAGE identifier OPEN_BRACE messageMemberList? CLOSE_BRACE
    // @define @name_fields(identifier) @symbol(kind=global) @scope(level=2)
    ;

categoryType#

antlr
categoryType: VALIDATION | RULE | SECURITY | INTEGRITY | IO | PERFORMANCE | DOMAIN | SYSTEM | USER | INFO | CUSTOM OPEN_PAREN stringLiteral CLOSE_PAREN;

messagePluralBody#

antlr
messagePluralBody: messagePluralLocale messagePluralLocale*;

Complete rule and token inventory#

text
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
severityLevel

Examples#

Parameterized message#

bl
message MissingApprovalPolicy {
  severity: error;
  category: validation;
  message: {
    en: "No approval policy exists for company {company_code}.";
  };
  params: {
    company_code: CompanyCode;
  };
}

Localized message block#

bl
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#

bl
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.
  • /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.
Source: packages/business/language/grammar-files/message.md