refactor: 프론트엔드 리펙토링
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
export type LocalDraft = Readonly<{
|
||||
draftId: string;
|
||||
title: string;
|
||||
body: string;
|
||||
}>;
|
||||
|
||||
export function createLocalDraft(values: LocalDraft): LocalDraft {
|
||||
const draftId = values.draftId.trim();
|
||||
const title = values.title.trim();
|
||||
if (!draftId || !title) {
|
||||
throw new TypeError("Local draft requires draftId and title");
|
||||
}
|
||||
if (title.length > 160 || values.body.length > 100_000) {
|
||||
throw new TypeError("Local draft exceeds bounded field limits");
|
||||
}
|
||||
return Object.freeze({
|
||||
draftId,
|
||||
title,
|
||||
body: values.body,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user