normalizeFeatureName function

String? normalizeFeatureName(
  1. String input
)

Normalises an arbitrary input into a valid snake_case feature name.

Returns null when the input cannot produce a valid name (for example when it is empty or would start with a digit after normalisation).

Examples:

  • "User Profile" -> "user_profile"
  • "userProfile" -> "user_profile"
  • "order-history" -> "order_history"
  • "123" -> null

Implementation

String? normalizeFeatureName(String input) {
  final snake = toSnakeCase(input);
  return isValidFeatureName(snake) ? snake : null;
}