-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathstructs.js
More file actions
31 lines (23 loc) · 848 Bytes
/
structs.js
File metadata and controls
31 lines (23 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as s from "superstruct";
export const CreateProduct = s.object({
name: s.size(s.string(), 1, 10),
description: s.size(s.string(), 10, 100),
price: s.min(s.number(), 1),
tags: s.optional(s.array(s.string())),
favoriteCount: s.optional(s.min(s.number(), 0)),
images: s.optional(s.array(s.string())),
});
export const UpdateProduct = s.partial(CreateProduct);
export const CreateProductComment = s.object({
content: s.string(),
});
export const UpdateProductComment = s.partial(CreateProductComment);
export const CreateArticle = s.object({
title: s.size(s.string(), 1, 100),
content: s.size(s.string(), 1, 1000),
});
export const UpdateArticle = s.partial(CreateArticle);
export const CreateArticleComment = s.object({
content: s.string(),
});
export const UpdateArticleComment = s.partial(CreateArticleComment);