Skip to content

Commit

Permalink
fix validateEvent() signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Dec 19, 2023
1 parent f77b9ea commit 2571db9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ describe('Event', () => {

test('should return false for a non object event', () => {
const nonObjectEvent = ''

const isValid = validateEvent(nonObjectEvent)

expect(isValid).toEqual(false)
})

Expand Down
2 changes: 1 addition & 1 deletion event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function getEventHash(event: UnsignedEvent): string {

const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object

export function validateEvent(event: UnsignedEvent): boolean {
export function validateEvent<T>(event: T): event is T & UnsignedEvent {
if (!isRecord(event)) return false
if (typeof event.kind !== 'number') return false
if (typeof event.content !== 'string') return false
Expand Down

0 comments on commit 2571db9

Please sign in to comment.