export function implementsIConnectionOptions()

in packages/aws-rfdk/lib/lambdas/nodejs/mongodb/types.ts [74:85]


export function implementsIConnectionOptions(value: any): boolean {
  if (!value || typeof(value) !== 'object') { return false; }
  if (!value.Hostname || typeof(value.Hostname) !== 'string') { return false; }
  if (!value.Port || typeof(value.Port) !== 'string') { return false; }
  const portNum = Number.parseInt(value.Port, 10);
  if (Number.isNaN(portNum) || portNum < 1 || portNum > 65535) { return false; }
  for (const key of ['Credentials', 'CaCertificate']) {
    if (!value[key] || typeof(value[key]) !== 'string') { return false; }
    if (!isSecretArn(value[key])) { return false; }
  }
  return true;
}