Validation Rules
The erbsland.conf.vr package provides ELCL rule loading, a Python keyword
builder and read-only rule metadata. See Validation Rules for examples.
Rules and Builder
- class Rules
An immutable schema. Each validation has its own indexes and traversal state.
- classmethod from_document(document: Document) Rules
Compile a parsed rules document, raising ConfValidationError for invalid definitions.
- classmethod loads(text: str) Rules
Parse and compile rules from ELCL text using the standard parser.
- classmethod load(path: str | Path) Rules
Parse and compile an ELCL rules file using the standard parser.
- validate(value: Value, version: int) None
Validate a document or section in place.
Insert defaults and attach metadata. The version must be a nonnegative integer. Raise ConfValidationError on the first failure; partial updates are possible on failure. Revalidation refreshes defaults and metadata only inside the supplied subtree.
- class RulesBuilder
Build a schema with native values and ordered keyword constraints.
Declare parent rules before their children. Returned branch views share this builder. Only the original builder can build or reset; reset invalidates old branch views. Building leaves the builder available for further editing.
- add_rule(path: str | Name | NamePath, type_: RuleType | Type[Any] | str, **options: Unpack[RuleOptions]) RulesBuilder
Declare a literal named rule and return its branch view.
- add_alternative(path: str | Name | NamePath, type_: RuleType | Type[Any] | str, **options: Unpack[RuleOptions]) RulesBuilder
Append an alternative and return a view for that alternative’s children.
- add_entry(type_: RuleType | Type[Any] | str, **options: Unpack[RuleOptions]) RulesBuilder
Declare the entry rule of this list.
- add_entry_alternative(type_: RuleType | Type[Any] | str, **options: Unpack[RuleOptions]) RulesBuilder
Append an alternative entry definition for this list.
- add_any(type_: RuleType | Type[Any] | str, **options: Unpack[RuleOptions]) RulesBuilder
Declare a wildcard for otherwise unmatched child names.
- add_any_alternative(type_: RuleType | Type[Any] | str, **options: Unpack[RuleOptions]) RulesBuilder
Append an alternative for otherwise unmatched child names.
- configure_name(**options: Unpack[RuleOptions]) None
Configure text constraints on this named rule or wildcard’s names.
- branch(path: str | Name | NamePath) RulesBuilder
Return a view of an existing literal named rule.
- configure_root(**options: Unpack[RuleOptions]) None
Configure this view’s root rule, preserving existing children.
- add_key(*paths: str | Name | NamePath, name: str | None = None, case_sensitive: bool = False) None
Declare a scoped unique index; multiple paths form a composite key.
- add_dependency(mode: DependencyMode | str, *, source: str | Name | NamePath | list[str | Name | NamePath] | tuple[str | Name | NamePath, ...], target: str | Name | NamePath | list[str | Name | NamePath] | tuple[str | Name | NamePath, ...], error: str = '') None
Require a relationship between explicitly configured relative paths.
Metadata and Types
- class Rule
Read-only rule metadata. Name paths are returned as independent copies.
- class Constraint
A compiled constraint, in declaration order; sequences are immutable tuples.
Keyword Options
- class RuleOptions
ELCL attributes as Python keywords, in evaluation order.