-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_schema.yaml
115 lines (104 loc) · 2.49 KB
/
sample_schema.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# this is a sample schema file, you can copy it and change anything you want
# faker config
faker:
locales:
- zh_CN
# - zh_TW
providers:
- address
- name: my_provider
source: sample_provider.txt
# generator params
params:
amount: 5
max_try: 100
format: csv # print(debug only), sql, csv
args:
separator: '|'
headers: true
quotation: double
# user's env params, will be passed to generators as context object
env:
foo: 43
bar:
fake: This is a fake sentence
# data schema
struct:
# it's a common table struct which stores students' info
# it will show some basic examples
student_info:
# basic generators examples
id:
type: int
rule: increase
value: 0
age:
rule: range
value: 12...18
sex:
rule: enum
value:
- 0
- 1
# eval generator (and basic usage of faker)
name:
rule: eval
value: fake.name() # built-in provider
address:
rule: eval
value: fake.address() # extended provider
id_card:
rule: eval
value: fake.my_provider() # customized provider
# regex generator
account_name:
rule: regex
value: '[A-Z]{2,3}_?\d{6}' # example: 'FZU_835486' or 'NS486245'
# this table will use some advance options or generators
grade_info:
# basic usage of foreign generator
id:
type: int
rule: foreign
value: student_info.id
args:
cast: one
# filter mode of foreign generator
name:
rule: foreign
value: student_info.name
args:
cast: filter
filters:
field: id
condition: field == line.id
# option 'if'
score:
type: int
rule: range
value: 50...100
rank:
- if: line.score >= 90
value: A
- if: line.score >= 80
value: B
- if: line.score >= 70
value: C
- value: D
# option 'order'
# we need the 'readjust' to judge whether he passed or not
# set order = 1 to make 'passed' generated later than 'readjust' (order = 0)
# so we can ref to readjust through 'line.readjust' in context
passed:
- if: line.score + line.readjust >= 70
order: 1
value: Passed!
# script sort fields by the max order of generators
# this 0 is equal to order 1
- order: 0
value: Failed...
# option 'limit'
readjust:
rule: range
value: -20...20
limit: line.score + value <= 100 and line.score + value >= 40