validateApiKeyToken function

Future<bool> validateApiKeyToken(
  1. String value
)

Validates the API key or token. Returns true if the value is a valid API key or token, otherwise throws an exception.

Implementation

Future<bool> validateApiKeyToken(String value) async {
  // Validate inputs
  // API key or token must be alphanumeric and length 64
  if (!RegExp(r'^[a-zA-Z0-9]{64}$').hasMatch(value)) {
    throw Exception('Invalid API key or token.');
  }

  return true;
}