Skip to content

Commit

Permalink
fix(utilities): Resolved issue with isSetObject passing invalid types
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed Jan 2, 2024
1 parent 97ec2c7 commit a6c1dcf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/api-reports/packages/logging/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export { LoggingConfig as LoggingConfig_alias_1 };
export const LoggingConfigSchema: z.ZodObject<
{
stacktrace: z.ZodOptional<z.ZodBoolean>;
fileLoggingDisabled: z.ZodDefault<z.ZodBoolean>;
fileName: z.ZodDefault<z.ZodOptional<z.ZodString>>;
fileExtension: z.ZodDefault<z.ZodString>;
path: z.ZodOptional<z.ZodString>;
Expand Down Expand Up @@ -155,6 +156,7 @@ export const LoggingConfigSchema: z.ZodObject<
"strip",
z.ZodTypeAny,
{
fileLoggingDisabled: boolean;
fileName: string;
fileExtension: string;
stacktrace?: boolean | undefined;
Expand All @@ -169,6 +171,7 @@ export const LoggingConfigSchema: z.ZodObject<
},
{
stacktrace?: boolean | undefined;
fileLoggingDisabled?: boolean | undefined;
fileName?: string | undefined;
fileExtension?: string | undefined;
path?: string | undefined;
Expand Down
22 changes: 20 additions & 2 deletions docs/api-reports/packages/logging/documents-model.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,24 @@
"text": "z.ZodBoolean",
"canonicalReference": "!z.ZodBoolean:type"
},
{
"kind": "Content",
"text": ">;\n fileLoggingDisabled: "
},
{
"kind": "Reference",
"text": "z.ZodDefault",
"canonicalReference": "!z.ZodDefault:type"
},
{
"kind": "Content",
"text": "<"
},
{
"kind": "Reference",
"text": "z.ZodBoolean",
"canonicalReference": "!z.ZodBoolean:type"
},
{
"kind": "Content",
"text": ">;\n fileName: "
Expand Down Expand Up @@ -2205,7 +2223,7 @@
},
{
"kind": "Content",
"text": ", {\n fileName: string;\n fileExtension: string;\n stacktrace?: boolean | undefined;\n path?: string | undefined;\n loki?: {\n host: string;\n username: string;\n password: string;\n } | undefined;\n}, {\n stacktrace?: boolean | undefined;\n fileName?: string | undefined;\n fileExtension?: string | undefined;\n path?: string | undefined;\n loki?: {\n username: string;\n password: string;\n host?: string | undefined;\n } | undefined;\n}>"
"text": ", {\n fileLoggingDisabled: boolean;\n fileName: string;\n fileExtension: string;\n stacktrace?: boolean | undefined;\n path?: string | undefined;\n loki?: {\n host: string;\n username: string;\n password: string;\n } | undefined;\n}, {\n stacktrace?: boolean | undefined;\n fileLoggingDisabled?: boolean | undefined;\n fileName?: string | undefined;\n fileExtension?: string | undefined;\n path?: string | undefined;\n loki?: {\n username: string;\n password: string;\n host?: string | undefined;\n } | undefined;\n}>"
}
],
"fileUrlPath": "packages/logging/src/schema.ts",
Expand All @@ -2214,7 +2232,7 @@
"name": "LoggingConfigSchema",
"variableTypeTokenRange": {
"startIndex": 1,
"endIndex": 37
"endIndex": 41
}
},
{
Expand Down
7 changes: 6 additions & 1 deletion packages/utilities/src/type-checks/is-set-object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isEmptyOrEmptyObject } from "./is-empty-object";
import { isObject } from "./is-object";

/**
* Check if the provided value's type is NOT `null` nor `undefined` nor `{}`
Expand All @@ -8,7 +9,11 @@ import { isEmptyOrEmptyObject } from "./is-empty-object";
*/
export const isSetObject = (value: unknown): value is NonNullable<object> => {
try {
return isEmptyOrEmptyObject(value);
return (
!isEmptyOrEmptyObject(value) &&
isObject(value) &&
Object.keys(value).length > 0
);
} catch (e) {
return true;
}
Expand Down

0 comments on commit a6c1dcf

Please sign in to comment.