FormulaId constructor

FormulaId(
  1. String value
)

Creates and validates a formula id.

Implementation

factory FormulaId(String value) {
  final trimmed = value.trim().toLowerCase();
  if (trimmed.isEmpty) {
    throw const ProtocolException('Formula id cannot be empty');
  }
  if (!_valid.hasMatch(trimmed)) {
    throw ProtocolException('Invalid formula id: "$value"');
  }
  return FormulaId._(trimmed);
}