Field grammar#
Field grammar describes reusable scalar fields, constraints, defaults, validation hooks, formatting hints, and field-level metadata.
Source#
| Property | Value |
|---|---|
| Grammar file | packages/business/language/grammar/field.g4 |
| Grammar name | field |
| Grammar kind | parser |
| Imports | common, literal, expression |
| Imported by | BusinessLanguage, entity, module |
| Direct rule or token count | 27 |
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#
fieldDeclaration
: annotation* fieldDeclarationCore
// @define @name_fields(identifier) @symbol(kind=global) @scope(level=2)
;fieldType#
fieldType: typeExpression;fieldValidationDeclaration#
fieldValidationDeclaration: VALIDATION OPEN_BRACE validationRuleList? CLOSE_BRACE;Complete rule and token inventory#
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, validationStatementExamples#
Reusable field type#
field InvoiceId: string {
max_length: 40;
key: true;
}Field with default#
field ActiveFlag: bool {
default: true;
}Localized label declaration#
label VendorLabels {
vendor_name: {
en: "Vendor name";
ar: "Vendor name";
};
}Reusable validation rule#
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.
Related guides#
- /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.