-
Notifications
You must be signed in to change notification settings - Fork 5
/
objectEntityContent.hbs
77 lines (64 loc) · 1.28 KB
/
objectEntityContent.hbs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{{#*inline "type"~}}
{{#if hasTypeImport}}{{ typeName }}{{else}}
{{#if (eq typeName "Date")}}
z.preprocess(arg => (typeof arg == "string" || arg instanceof Date ? new Date(arg) : undefined), z.date())
{{~else}}z.{{ typeName }}(){{/if}}
{{~/if}}
{{/inline~}}
{{#*inline "validation"}}
{{#with (lookup rawValidations "number") }}
/* is number */
{{~/with}}
{{#if (eq typeName "string") }}
{{#if rawValidations.minLength}}
.min({{rawValidations.minLength}})
{{~else}}
{{#if required}}
.min(1)
{{~/if}}
{{~/if}}
{{#if rawValidations.maxLength}}
.max({{rawValidations.maxLength}})
{{~/if}}
{{#if (eq format "email")}}
.email()
{{~/if}}
{{~/if}}
{{~/inline~}}
{{#*inline "property"}}
{{#if example}}
/**
* @example
* {{{example}}}
*/
{{/if}}
{{name}}:
{{~#if isArray}}
z.array({{> type}})
{{else}}
{{> type}}
{{/if}}
{{~> validation~}}
{{#unless required}}
.optional()
{{~/unless}}
{{#if nullable}}
.nullable()
{{~/if}}
{{#if description}}
.describe("{{inline description}}")
{{~/if}}
,
{{/inline}}
return z
.object({
{{#each properties}}
{{> property}}
{{#unless @last}}
{{/unless}}
{{/each}}
})
{{#each baseClasses}}
.merge({{name}})
{{/each}}
.describe("{{entity.name}}");