Skip to content

Commit

Permalink
feat: implement type assertion for record link token
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSebastianDev committed Feb 26, 2023
1 parent e02d4bc commit 7703dd5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib/Validators/isRecordLink.util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @format */

import { RecordLink } from '../../types';
import { ObjectId } from '../Db';

export const isRecordLink = (value: unknown): value is RecordLink => {
if (typeof value !== 'string') return false;

const [namespace, id] = value.split(':');

return !!(namespace && ObjectId.is(id));
};

0 comments on commit 7703dd5

Please sign in to comment.