-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschemas.ts
56 lines (51 loc) · 1.53 KB
/
schemas.ts
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
import { z } from 'zod'
import { Severity, Switch } from './types'
export const keywordInts = z
.object({
feature: z.number(),
background: z.number(),
scenario: z.number(),
step: z.number(),
examples: z.number(),
given: z.number(),
when: z.number(),
then: z.number(),
and: z.number(),
but: z.number(),
exampleTableHeader: z.number(),
exampleTableBody: z.number(),
})
.partial()
.strict()
// warn | error
export const severitySchema = z.nativeEnum(Severity)
// on | off | warn | error
export const switchOrSeveritySchema = z.union([z.nativeEnum(Switch), z.nativeEnum(Severity)])
export const switchOrSeverityorSeverityAndStringSchema = z.union([
z.nativeEnum(Switch),
z.nativeEnum(Severity),
z.tuple([z.nativeEnum(Severity), z.string()]),
])
// off | on | error | warn | [error | warn, string]
export const offOrStringArrayOrSeverityAndStringArray = z.union([
z.literal(Switch.off),
z.string().array(),
z.tuple([severitySchema, z.string().array()]),
])
// off | keywordInts | [warn | error, keywordInts]
export const offOrKeywordIntsOrSeverityAndKeywordInts = z.union([
z.literal(Switch.off),
keywordInts,
z.tuple([z.nativeEnum(Severity), keywordInts]),
])
export const offOrNumberOrSeverityAndNumber = z.union([
z.literal(Switch.off),
z.number(),
z.tuple([z.nativeEnum(Severity), z.number()]),
])
export const offOrNumberOrSeverityOrSeverityAndNumber = z.union([
z.literal(Switch.off),
z.number(),
z.nativeEnum(Severity),
z.tuple([z.nativeEnum(Severity), z.number()]),
])