N NezamDocumentation

Field grammar#

Field grammar describes reusable scalar fields, constraints, defaults, validation hooks, formatting hints, and field-level metadata.

Source#

PropertyValue
Grammar filepackages/business/language/grammar/field.g4
Grammar namefield
Grammar kindparser
Importscommon, literal, expression
Imported byBusinessLanguage, entity, module
Direct rule or token count27

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: fieldDeclaration, fieldType, fieldValidationDeclaration, labelDeclaration, validationRuleDeclaration, validationRuleBody, validationStatement.

  • Declarations: fieldDeclaration, fieldValidationDeclaration, labelDeclaration, validationRuleDeclaration
  • Statements: validationStatement
  • Types: fieldType
  • Bodies: validationRuleBody

Key grammar excerpts#

fieldDeclaration#

antlr
fieldDeclaration
    : annotation* fieldDeclarationCore
      // @define @name_fields(identifier) @symbol(kind=global) @scope(level=2)
    ;

fieldType#

antlr
fieldType: typeExpression;

fieldValidationDeclaration#

antlr
fieldValidationDeclaration: VALIDATION OPEN_BRACE validationRuleList? CLOSE_BRACE;

Complete rule and token inventory#

text
fieldBlock, fieldBlockMember, fieldBlockMemberList, fieldDeclaration, fieldDeclarationCore, fieldMember, fieldProperty, fieldPropertyName
fieldType, fieldValidationDeclaration, labelAnnotation, labelContent, labelDeclaration, labelMember, labelMemberList, languageCode
localizationBlock, localizedEntry, localizedEntryList, validationExpr, validationRule, validationRuleBody, validationRuleBodyList, validationRuleDeclaration
validationRuleList, validationRuleReference, validationStatement

Examples#

Reusable field type#

bl
field InvoiceId: string {
  max_length: 40;
  key: true;
}

Field with default#

bl
field ActiveFlag: bool {
  default: true;
}

Localized label declaration#

bl
label VendorLabels {
  vendor_name: {
    en: "Vendor name";
    ar: "Vendor name";
  };
}

Reusable validation rule#

bl
validation rule RequiredText {
  require value is not null else "RequiredText";
}

Common authoring mistakes#

  • Do not copy examples without checking the rule inventory for the exact grammar boundary.
  • Do not add behavior that depends on missing configuration or undeclared user-facing errors.
  • /language/data-modeling/
  • /language/types-literals/

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/field.md