validateSchema method

void validateSchema()

Validates runtime schema invariants that cannot rely on debug-only asserts.

Field definitions keep const constructors for ergonomic schema declarations, so the dataset calls this during schema indexing to enforce public field metadata rules in debug and release builds.

Implementation

void validateSchema() {
  if (name.isEmpty) {
    throw ArgumentError.value(
      name,
      'name',
      'FdcFieldDef.name is required and must not be empty.',
    );
  }
  if (isKey && (isCalculated || !isPersistent)) {
    throw ArgumentError.value(
      isKey,
      'isKey',
      'Key field "$name" must be persistent and non-calculated.',
    );
  }
  if (name.trim() != name) {
    throw ArgumentError.value(
      name,
      'name',
      'FdcFieldDef.name must not have leading or trailing whitespace.',
    );
  }
}