dynamic-forms / Function

validateNoCycles

Validates a derivation collection and throws if cycles are detected.

This is the main entry point for cycle validation during form initialization. Should be called after collecting derivations and before setting up effects.

In dev mode, logs a warning when bidirectional derivation pairs are detected. These patterns are allowed but may oscillate with floating-point values.

Presentation

function validateNoCycles(
  collection: DerivationCollection,
  logger?: Logger | undefined,
): void;

Returns

void

Parameters

NameTypeDescription
collection
DerivationCollection

The collected derivation entries to validate

logger
Logger | undefined

Optional logger for dev-mode warnings

Example usage

const collection = collectDerivations(fields);

// This will throw if cycles exist
validateNoCycles(collection, logger);

// Safe to set up derivation effects now
setupDerivationEffects(collection);