ensureValidRecordKey function
Ensures recordKey is a syntactically valid Record Key.
Throws an InvalidRecordKeyError if recordKey is not a valid
Record Key.
Implementation
void ensureValidRecordKey(final String recordKey) {
if (recordKey.isEmpty || recordKey.length > 512) {
throw InvalidRecordKeyError('Record key must be 1 to 512 characters');
}
// Specific values that are not allowed.
if (recordKey == '.' || recordKey == '..') {
throw InvalidRecordKeyError('Record key can not be "." or ".."');
}
if (!_recordKeyRegExp.hasMatch(recordKey)) {
throw InvalidRecordKeyError('Record key syntax not valid (regex)');
}
}