function deconstructInterface()

in src/declarative-stack.ts [245:264]


function deconstructInterface(stack: cdk.Stack, typeRef: reflect.TypeReference, key: string, value: any) {
  if (!isSerializableInterface(typeRef.type)) {
    return undefined;
  }

  const out: any = { };
  for (const prop of typeRef.type.allProperties) {
    const propValue = value[prop.name];
    if (!propValue) {
      if (!prop.optional) {
        throw new ValidationError(`Missing required property ${key}.${prop.name} in ${typeRef}`);
      }
      continue;
    }

    out[prop.name] = deserializeValue(stack, prop.type, prop.optional, `${key}.${prop.name}`, propValue);
  }

  return out;
}