Skip to content

Commit db839db

Browse files
committed
refactor(core): isPlainObject moved from validation utils to type-guards utils
1 parent 984b5df commit db839db

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

packages/core/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export type { RandomGenerator } from './utils/random';
33
export { HawkUserManager } from './users/hawk-user-manager';
44
export type { Logger, LogType } from './logger/logger';
55
export { isLoggerSet, setLogger, resetLogger, log } from './logger/logger';
6-
export { isPlainObject, validateUser, validateContext, isValidEventPayload, isValidBreadcrumb } from './utils/validation';
6+
export { validateUser, validateContext, isValidEventPayload, isValidBreadcrumb } from './utils/validation';
7+
export { isPlainObject } from './utils/type-guards';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Checks if value is a plain object (not null, array, Date, Map, etc.)
3+
*
4+
* @param value - value to check
5+
* @returns `true` if value is a plain object, otherwise `false`
6+
*/
7+
export function isPlainObject(value: unknown): value is Record<string, unknown> {
8+
return Object.prototype.toString.call(value) === '[object Object]';
9+
}

packages/core/src/utils/validation.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { log } from '../logger/logger';
22
import type { AffectedUser, Breadcrumb, EventAddons, EventContext, EventData } from '@hawk.so/types';
3+
import { isPlainObject } from './type-guards';
34

45
/**
56
* Validates user data - basic security checks
@@ -38,16 +39,6 @@ export function validateContext(context: EventContext | undefined): boolean {
3839
return true;
3940
}
4041

41-
/**
42-
* Checks if value is a plain object (not null, array, Date, Map, etc.)
43-
*
44-
* @param value - value to check
45-
* @returns `true` if value is a plain object, otherwise `false`
46-
*/
47-
export function isPlainObject(value: unknown): value is Record<string, unknown> {
48-
return Object.prototype.toString.call(value) === '[object Object]';
49-
}
50-
5142
/**
5243
* Runtime check for required EventData fields.
5344
* Per @hawk.so/types EventData, `title` is the only non-optional field.

0 commit comments

Comments
 (0)