Skip to content

Commit

Permalink
feat(model/note): define Note data model
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaschiang committed Sep 1, 2021
1 parent de08455 commit 4a3de50
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/model/note.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { isJSON } from 'lib/model/json';

export interface Note {
message: string;
user: number;
highlight: number;
id: number;
text: string;
}

export function isNote(note: unknown): note is Note {
if (!isJSON(note)) return false;
return (
typeof note.message === 'string' &&
typeof note.user === 'number' &&
typeof note.highlight === 'number' &&
typeof note.id === 'number' &&
typeof note.text === 'string'
);
}

0 comments on commit 4a3de50

Please sign in to comment.