testRule property

  1. @override
TestTissue<E, C> get testRule
override

The TestTissue validation logic used to guard the integrity and state consistency of the reactive tissue.

The testRule acts as a functional "gatekeeper" during the tissue's mutation cycle. Before any mutation pulse (such as add, remove, or update) is applied to the underlying container, the framework invokes this rule to determine if the proposed change is valid within the current context.

Where to start

You typically set this when creating a collection via the Tissue factories. For example:

final list = TissueList<int>(
  testRule: TestTissue<int>((v) => v >= 0),
);

When to use

Read this when you need to understand what validation rules are applied to the collection – e.g., for conditional UI logic (disabling an "Add" button) or for debugging.

How it works

  1. Local Lookup: First attempts to retrieve the testRule defined directly in the current nucleus's record.
  2. Parental Inheritance: If not found, it recursively "walks up" the principal chain to find the rule from an ancestor.
  3. Default Fallback: If the root is reached without finding a rule, it defaults to TestTissue.allowAll – no restrictions.

Example

final list = TissueList<int>(testRule: TestTissue<int>((v) => v > 0));
print(list.validate); // the TestTissue instance

Returns:

The resolved TestTissue<E, C> providing the validation logic.

Implementation

@override
TestTissue<E, C> get testRule {
  return get<TestTissue<E, C>>(() => record.local.inheritable.testRule,
      fallback: () => principal?.testRule, orElse: TestTissue.allowAll);
}