validateStateKey function
Validates and normalizes an Mp state key.
Implementation
String validateStateKey(String key) {
final normalized = key.trim();
if (!_stateKeyPattern.hasMatch(normalized)) {
throw ArgumentError.value(
key,
'key',
'Mp state keys must be lowercase dot paths.',
);
}
for (final segment in normalized.split('.')) {
final compact = segment.replaceAll('_', '').toLowerCase();
if (_blockedStateSegments.contains(compact)) {
throw ArgumentError.value(
key,
'key',
'Mp state keys cannot contain secret-like segments.',
);
}
}
return normalized;
}