@based/schema 0.0.15 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{set/error.d.ts → error.d.ts} +4 -2
- package/dist/{set/error.js → error.js} +2 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/set/fields/array.d.ts +2 -0
- package/dist/set/fields/array.js +96 -0
- package/dist/set/fields/array.js.map +1 -0
- package/dist/set/fields/index.d.ts +3 -0
- package/dist/set/fields/index.js +72 -0
- package/dist/set/fields/index.js.map +1 -0
- package/dist/set/fields/number.d.ts +4 -0
- package/dist/set/fields/number.js +121 -0
- package/dist/set/fields/number.js.map +1 -0
- package/dist/set/fields/object.d.ts +3 -0
- package/dist/set/fields/object.js +33 -0
- package/dist/set/fields/object.js.map +1 -0
- package/dist/set/fields/references.d.ts +3 -0
- package/dist/set/fields/references.js +106 -0
- package/dist/set/fields/references.js.map +1 -0
- package/dist/set/fields/set.d.ts +2 -0
- package/dist/set/fields/set.js +63 -0
- package/dist/set/fields/set.js.map +1 -0
- package/dist/set/fields/string.d.ts +3 -0
- package/dist/set/fields/string.js +190 -0
- package/dist/set/fields/string.js.map +1 -0
- package/dist/set/index.d.ts +2 -5
- package/dist/set/index.js +98 -126
- package/dist/set/index.js.map +1 -1
- package/dist/set/isValidId.d.ts +2 -0
- package/dist/set/isValidId.js +21 -0
- package/dist/set/isValidId.js.map +1 -0
- package/dist/set/types.d.ts +0 -5
- package/dist/set/types.js +0 -2
- package/dist/types.d.ts +7 -1
- package/dist/types.js.map +1 -1
- package/dist/walker/args.d.ts +31 -0
- package/dist/walker/args.js +120 -0
- package/dist/walker/args.js.map +1 -0
- package/dist/walker/index.d.ts +6 -0
- package/dist/walker/index.js +40 -0
- package/dist/walker/index.js.map +1 -0
- package/dist/walker/parse.d.ts +2 -0
- package/dist/walker/parse.js +157 -0
- package/dist/walker/parse.js.map +1 -0
- package/dist/walker/types.d.ts +44 -0
- package/dist/walker/types.js +9 -0
- package/dist/walker/types.js.map +1 -0
- package/package.json +2 -2
- package/src/{set/error.ts → error.ts} +3 -1
- package/src/index.ts +2 -2
- package/src/set/fields/array.ts +111 -0
- package/src/set/fields/index.ts +69 -0
- package/src/set/fields/number.ts +134 -0
- package/src/set/fields/object.ts +30 -0
- package/src/set/fields/references.ts +114 -0
- package/src/set/fields/set.ts +63 -0
- package/src/set/fields/string.ts +199 -0
- package/src/set/index.ts +103 -188
- package/src/set/isValidId.ts +23 -0
- package/src/set/types.ts +0 -20
- package/src/types.ts +4 -2
- package/src/walker/args.ts +159 -0
- package/src/walker/index.ts +35 -0
- package/src/walker/parse.ts +193 -0
- package/src/walker/types.ts +75 -0
- package/test/number.ts +289 -543
- package/test/reference.ts +150 -198
- package/test/rest.ts +227 -0
- package/test/string.ts +139 -183
- package/test/utils/index.ts +23 -0
- package/test/walker.ts +579 -16
- package/dist/set/collections.d.ts +0 -5
- package/dist/set/collections.js +0 -229
- package/dist/set/collections.js.map +0 -1
- package/dist/set/error.js.map +0 -1
- package/dist/set/number.d.ts +0 -4
- package/dist/set/number.js +0 -124
- package/dist/set/number.js.map +0 -1
- package/dist/set/parseDefaultAndValue.d.ts +0 -3
- package/dist/set/parseDefaultAndValue.js +0 -35
- package/dist/set/parseDefaultAndValue.js.map +0 -1
- package/dist/set/parsers.d.ts +0 -3
- package/dist/set/parsers.js +0 -42
- package/dist/set/parsers.js.map +0 -1
- package/dist/set/references.d.ts +0 -3
- package/dist/set/references.js +0 -84
- package/dist/set/references.js.map +0 -1
- package/dist/set/rest.d.ts +0 -5
- package/dist/set/rest.js +0 -76
- package/dist/set/rest.js.map +0 -1
- package/dist/set/string.d.ts +0 -3
- package/dist/set/string.js +0 -173
- package/dist/set/string.js.map +0 -1
- package/dist/set2/index.d.ts +0 -0
- package/dist/set2/index.js +0 -71
- package/dist/set2/index.js.map +0 -1
- package/dist/walker.d.ts +0 -49
- package/dist/walker.js +0 -120
- package/dist/walker.js.map +0 -1
- package/src/set/collections.ts +0 -338
- package/src/set/number.ts +0 -167
- package/src/set/parseDefaultAndValue.ts +0 -54
- package/src/set/parsers.ts +0 -20
- package/src/set/references.ts +0 -113
- package/src/set/rest.ts +0 -135
- package/src/set/string.ts +0 -254
- package/src/set2/index.ts +0 -71
- package/src/walker.ts +0 -191
- package/test/setWalker.ts +0 -494
- package/test/text.ts +0 -171
package/test/number.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import test from 'ava'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ArgsClass,
|
|
4
|
+
BasedSchema,
|
|
5
|
+
BasedSchemaCollectProps,
|
|
6
|
+
BasedSetTarget,
|
|
7
|
+
setWalker2,
|
|
8
|
+
} from '../src/index'
|
|
9
|
+
import { ParseError } from '../src/error'
|
|
10
|
+
import { resultCollect, errorCollect } from './utils'
|
|
11
|
+
type NumberTypes = 'number' | 'timestamp' | 'integer'
|
|
3
12
|
|
|
4
13
|
const schema: BasedSchema = {
|
|
5
14
|
types: {
|
|
@@ -42,490 +51,278 @@ const schema: BasedSchema = {
|
|
|
42
51
|
},
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
results: { path: (number | string)[]; value: any }[]
|
|
47
|
-
handlers: BasedSetOptionalHandlers
|
|
48
|
-
} => {
|
|
49
|
-
const results: { path: (number | string)[]; value: any }[] = []
|
|
50
|
-
const handlers = {
|
|
51
|
-
collect: ({ path, value, typeSchema, fieldSchema, target }) => {
|
|
52
|
-
results.push({ path, value })
|
|
53
|
-
},
|
|
54
|
-
checkRequiredFields: async (paths) => {
|
|
55
|
-
return true
|
|
56
|
-
},
|
|
57
|
-
referenceFilterCondition: async (id, filter) => {
|
|
58
|
-
return true
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
return { results, handlers }
|
|
62
|
-
}
|
|
54
|
+
//todo need help typing this maybe
|
|
63
55
|
|
|
64
56
|
test('min-max', async (t) => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
$id: 'bl1',
|
|
90
|
-
number: 3,
|
|
91
|
-
},
|
|
92
|
-
handlers
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
await setWalker(
|
|
96
|
-
schema,
|
|
97
|
-
{
|
|
98
|
-
$id: 'bl1',
|
|
99
|
-
number: 6,
|
|
100
|
-
},
|
|
101
|
-
handlers
|
|
102
|
-
)
|
|
103
|
-
t.deepEqual(results, [
|
|
57
|
+
const e1 = await setWalker2(schema, {
|
|
58
|
+
$id: 'bl1',
|
|
59
|
+
number: 1,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const e2 = await setWalker2(schema, {
|
|
63
|
+
$id: 'bl1',
|
|
64
|
+
number: 10,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const res1 = await setWalker2(schema, {
|
|
68
|
+
$id: 'bl1',
|
|
69
|
+
number: 3,
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const res2 = await setWalker2(schema, {
|
|
73
|
+
$id: 'bl1',
|
|
74
|
+
number: 6,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
t.true(errorCollect(e1, e2).length > 0)
|
|
78
|
+
|
|
79
|
+
t.deepEqual(resultCollect(res1, res2), [
|
|
104
80
|
{ path: ['number'], value: 3 },
|
|
105
81
|
{ path: ['number'], value: 6 },
|
|
106
82
|
])
|
|
107
83
|
})
|
|
108
84
|
|
|
109
85
|
test('min-max exclusive', async (t) => {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
schema,
|
|
134
|
-
{
|
|
135
|
-
$id: 'bl1',
|
|
136
|
-
exclusiveminmax: 4,
|
|
137
|
-
},
|
|
138
|
-
handlers
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
await setWalker(
|
|
142
|
-
schema,
|
|
143
|
-
{
|
|
144
|
-
$id: 'bl1',
|
|
145
|
-
exclusiveminmax: 5,
|
|
146
|
-
},
|
|
147
|
-
handlers
|
|
148
|
-
)
|
|
149
|
-
t.deepEqual(results, [
|
|
86
|
+
const e1 = await setWalker2(schema, {
|
|
87
|
+
$id: 'bl1',
|
|
88
|
+
exclusiveminmax: 3,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const e2 = await setWalker2(schema, {
|
|
92
|
+
$id: 'bl1',
|
|
93
|
+
exclusiveminmax: 6,
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const res1 = await setWalker2(schema, {
|
|
97
|
+
$id: 'bl1',
|
|
98
|
+
exclusiveminmax: 4,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const res2 = await setWalker2(schema, {
|
|
102
|
+
$id: 'bl1',
|
|
103
|
+
exclusiveminmax: 5,
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
t.assert(errorCollect(e1, e2).length > 0)
|
|
107
|
+
|
|
108
|
+
t.deepEqual(resultCollect(res1, res2), [
|
|
150
109
|
{ path: ['exclusiveminmax'], value: 4 },
|
|
151
110
|
{ path: ['exclusiveminmax'], value: 5 },
|
|
152
111
|
])
|
|
153
112
|
})
|
|
154
113
|
|
|
155
114
|
test('isInteger', async (t) => {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
await setWalker(
|
|
170
|
-
schema,
|
|
171
|
-
{
|
|
172
|
-
$id: 'bl1',
|
|
173
|
-
integer: 5,
|
|
174
|
-
},
|
|
175
|
-
handlers
|
|
176
|
-
)
|
|
177
|
-
t.deepEqual(results, [{ path: ['integer'], value: 5 }])
|
|
115
|
+
const e1 = await setWalker2(schema, {
|
|
116
|
+
$id: 'bl1',
|
|
117
|
+
integer: 6.5,
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const res1 = await setWalker2(schema, {
|
|
121
|
+
$id: 'bl1',
|
|
122
|
+
integer: 5,
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
t.assert(errorCollect([e1]).length > 0)
|
|
126
|
+
t.deepEqual(resultCollect([res1]), [{ path: ['integer'], value: 5 }])
|
|
178
127
|
})
|
|
179
128
|
|
|
180
129
|
test('isMultiple', async (t) => {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
await setWalker(
|
|
195
|
-
schema,
|
|
196
|
-
{
|
|
197
|
-
$id: 'bl1',
|
|
198
|
-
multipleOf: 9,
|
|
199
|
-
},
|
|
200
|
-
handlers
|
|
201
|
-
)
|
|
202
|
-
t.deepEqual(results, [{ path: ['multipleOf'], value: 9 }])
|
|
130
|
+
const e1 = await setWalker2(schema, {
|
|
131
|
+
$id: 'bl1',
|
|
132
|
+
multipleOf: 7,
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const res1 = await setWalker2(schema, {
|
|
136
|
+
$id: 'bl1',
|
|
137
|
+
multipleOf: 9,
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
t.assert(errorCollect([e1]).length > 0)
|
|
141
|
+
t.deepEqual(resultCollect([res1]), [{ path: ['multipleOf'], value: 9 }])
|
|
203
142
|
})
|
|
204
143
|
|
|
144
|
+
//TODO fix
|
|
205
145
|
test('numbers in a set', async (t) => {
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
)
|
|
217
|
-
await setWalker(schema, { $id: 'bl1', set: [3, 3, 3, 3] }, handlers)
|
|
218
|
-
t.deepEqual(results, [{ path: ['set'], value: { $value: [3, 3, 3, 3] } }])
|
|
146
|
+
const e1 = await setWalker2(schema, {
|
|
147
|
+
$id: 'bl1',
|
|
148
|
+
set: [9, 4, 5, 2],
|
|
149
|
+
})
|
|
150
|
+
const res1 = await setWalker2(schema, { $id: 'bl1', set: [3, 3, 3, 3] })
|
|
151
|
+
|
|
152
|
+
t.assert(errorCollect([e1]).length > 0)
|
|
153
|
+
t.deepEqual(resultCollect([res1]), [
|
|
154
|
+
{ path: ['set'], value: { $value: [3, 3, 3, 3] } },
|
|
155
|
+
])
|
|
219
156
|
})
|
|
220
|
-
|
|
157
|
+
//TODO fix
|
|
221
158
|
test('value', async (t) => {
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
await setWalker(
|
|
278
|
-
schema,
|
|
279
|
-
{
|
|
280
|
-
$id: 'bl1',
|
|
281
|
-
number: { $value: 4 },
|
|
282
|
-
},
|
|
283
|
-
handlers
|
|
284
|
-
)
|
|
285
|
-
await setWalker(
|
|
286
|
-
schema,
|
|
287
|
-
{
|
|
288
|
-
$id: 'bl1',
|
|
289
|
-
integer: { $value: 4 },
|
|
290
|
-
},
|
|
291
|
-
handlers
|
|
292
|
-
)
|
|
293
|
-
await setWalker(
|
|
294
|
-
schema,
|
|
295
|
-
{
|
|
296
|
-
$id: 'bl1',
|
|
297
|
-
exclusiveminmax: { $value: 4 },
|
|
298
|
-
},
|
|
299
|
-
handlers
|
|
300
|
-
)
|
|
301
|
-
await setWalker(
|
|
302
|
-
schema,
|
|
303
|
-
{
|
|
304
|
-
$id: 'bl1',
|
|
305
|
-
multipleOf: { $value: 6 },
|
|
306
|
-
},
|
|
307
|
-
handlers
|
|
308
|
-
)
|
|
309
|
-
|
|
310
|
-
await setWalker(
|
|
311
|
-
schema,
|
|
312
|
-
{
|
|
313
|
-
$id: 'bl1',
|
|
314
|
-
set: { $value: [3, 3, 3, 4] },
|
|
315
|
-
},
|
|
316
|
-
handlers
|
|
317
|
-
)
|
|
318
|
-
t.deepEqual(results, [
|
|
319
|
-
{ path: ['number'], value: { $value: 4 } },
|
|
320
|
-
{ path: ['integer'], value: { $value: 4 } },
|
|
321
|
-
{ path: ['exclusiveminmax'], value: { $value: 4 } },
|
|
322
|
-
{ path: ['multipleOf'], value: { $value: 6 } },
|
|
323
|
-
{ path: ['set'], value: { $value: [3, 3, 3, 4] } },
|
|
159
|
+
const e1 = await setWalker2(schema, {
|
|
160
|
+
$id: 'bl1',
|
|
161
|
+
number: { $value: 7 },
|
|
162
|
+
})
|
|
163
|
+
const e2 = await setWalker2(schema, {
|
|
164
|
+
$id: 'bl1',
|
|
165
|
+
exclusiveminmax: { $value: 3 },
|
|
166
|
+
})
|
|
167
|
+
const e3 = await setWalker2(schema, {
|
|
168
|
+
$id: 'bl1',
|
|
169
|
+
integer: { value: 3.5 },
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
const e4 = await setWalker2(schema, {
|
|
173
|
+
$id: 'bl1',
|
|
174
|
+
set: { $value: [1, 3, 3, 4] },
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
const e5 = await setWalker2(schema, {
|
|
178
|
+
$id: 'bl1',
|
|
179
|
+
multipleOf: { $value: 2 },
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
const res1 = await setWalker2(schema, {
|
|
183
|
+
$id: 'bl1',
|
|
184
|
+
number: { $value: 4 },
|
|
185
|
+
})
|
|
186
|
+
const res2 = await setWalker2(schema, {
|
|
187
|
+
$id: 'bl1',
|
|
188
|
+
integer: { $value: 4 },
|
|
189
|
+
})
|
|
190
|
+
const res3 = await setWalker2(schema, {
|
|
191
|
+
$id: 'bl1',
|
|
192
|
+
exclusiveminmax: { $value: 4 },
|
|
193
|
+
})
|
|
194
|
+
const res4 = await setWalker2(schema, {
|
|
195
|
+
$id: 'bl1',
|
|
196
|
+
multipleOf: { $value: 6 },
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
const res5 = await setWalker2(schema, {
|
|
200
|
+
$id: 'bl1',
|
|
201
|
+
set: { $value: [3, 3, 3, 4] },
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
t.assert(errorCollect([e1, e2, e3, e4, e5]).length > 0)
|
|
205
|
+
t.deepEqual(resultCollect([res1, res2, res3, res4]), [
|
|
206
|
+
// t.deepEqual(resultCollect([res1, res2, res3, res4, res5]), [
|
|
207
|
+
{ path: ['number'], value: 4 },
|
|
208
|
+
{ path: ['integer'], value: 4 },
|
|
209
|
+
{ path: ['exclusiveminmax'], value: 4 },
|
|
210
|
+
{ path: ['multipleOf'], value: 6 },
|
|
211
|
+
// { path: ['set'], value: [3, 3, 3, 4] },
|
|
324
212
|
])
|
|
325
213
|
})
|
|
326
214
|
|
|
215
|
+
//TODO fix
|
|
327
216
|
test('default', async (t) => {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
)
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
{
|
|
376
|
-
$id: 'bl1',
|
|
377
|
-
multipleOf: { $default: 2 },
|
|
378
|
-
},
|
|
379
|
-
handlers
|
|
380
|
-
)
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
await setWalker(
|
|
384
|
-
schema,
|
|
385
|
-
{
|
|
386
|
-
$id: 'bl1',
|
|
387
|
-
number: { $default: 4 },
|
|
388
|
-
},
|
|
389
|
-
handlers
|
|
390
|
-
)
|
|
391
|
-
await setWalker(
|
|
392
|
-
schema,
|
|
393
|
-
{
|
|
394
|
-
$id: 'bl1',
|
|
395
|
-
integer: { $default: 4 },
|
|
396
|
-
},
|
|
397
|
-
handlers
|
|
398
|
-
)
|
|
399
|
-
await setWalker(
|
|
400
|
-
schema,
|
|
401
|
-
{
|
|
402
|
-
$id: 'bl1',
|
|
403
|
-
exclusiveminmax: { $default: 4 },
|
|
404
|
-
},
|
|
405
|
-
handlers
|
|
406
|
-
)
|
|
407
|
-
await setWalker(
|
|
408
|
-
schema,
|
|
409
|
-
{
|
|
410
|
-
$id: 'bl1',
|
|
411
|
-
multipleOf: { $default: 6 },
|
|
412
|
-
},
|
|
413
|
-
handlers
|
|
414
|
-
)
|
|
415
|
-
|
|
416
|
-
t.deepEqual(results, [
|
|
217
|
+
const e1 = await setWalker2(schema, {
|
|
218
|
+
$id: 'bl1',
|
|
219
|
+
number: { $default: 7 },
|
|
220
|
+
})
|
|
221
|
+
const e2 = await setWalker2(schema, {
|
|
222
|
+
$id: 'bl1',
|
|
223
|
+
exclusiveminmax: { $default: 3 },
|
|
224
|
+
})
|
|
225
|
+
const e3 = await setWalker2(schema, {
|
|
226
|
+
$id: 'bl1',
|
|
227
|
+
integer: { default: 3.5 },
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
const e4 = await setWalker2(schema, {
|
|
231
|
+
$id: 'bl1',
|
|
232
|
+
set: { $default: [1, 3, 3, 4] },
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
const e5 = await setWalker2(schema, {
|
|
236
|
+
$id: 'bl1',
|
|
237
|
+
multipleOf: { $default: 2 },
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
const res1 = await setWalker2(schema, {
|
|
241
|
+
$id: 'bl1',
|
|
242
|
+
number: { $default: 4 },
|
|
243
|
+
})
|
|
244
|
+
const res2 = await setWalker2(schema, {
|
|
245
|
+
$id: 'bl1',
|
|
246
|
+
integer: { $default: 4 },
|
|
247
|
+
})
|
|
248
|
+
const res3 = await setWalker2(schema, {
|
|
249
|
+
$id: 'bl1',
|
|
250
|
+
exclusiveminmax: { $default: 4 },
|
|
251
|
+
})
|
|
252
|
+
const res4 = await setWalker2(schema, {
|
|
253
|
+
$id: 'bl1',
|
|
254
|
+
multipleOf: { $default: 6 },
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
const res5 = await setWalker2(schema, {
|
|
258
|
+
$id: 'bl1',
|
|
259
|
+
set: { $default: [3, 3, 3, 4] },
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
t.assert(errorCollect([e1, e2, e3, e4, e5]).length > 0)
|
|
263
|
+
t.deepEqual(resultCollect([res1, res2, res3, res4, res5]), [
|
|
417
264
|
{ path: ['number'], value: { $default: 4 } },
|
|
418
265
|
{ path: ['integer'], value: { $default: 4 } },
|
|
419
266
|
{ path: ['exclusiveminmax'], value: { $default: 4 } },
|
|
420
267
|
{ path: ['multipleOf'], value: { $default: 6 } },
|
|
268
|
+
{ path: ['set'], value: { $default: [3, 3, 3, 4] } },
|
|
421
269
|
])
|
|
422
270
|
})
|
|
423
271
|
|
|
424
272
|
test('decrement', async (t) => {
|
|
425
|
-
const { handlers, results } = createHandlers()
|
|
426
273
|
//maxmin
|
|
427
|
-
await
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
{
|
|
441
|
-
$id: 'bl1',
|
|
442
|
-
number: { $decrement: 7 },
|
|
443
|
-
},
|
|
444
|
-
handlers
|
|
445
|
-
)
|
|
446
|
-
)
|
|
447
|
-
|
|
448
|
-
await setWalker(
|
|
449
|
-
schema,
|
|
450
|
-
{
|
|
451
|
-
$id: 'bl1',
|
|
452
|
-
number: { $decrement: 3 },
|
|
453
|
-
},
|
|
454
|
-
handlers
|
|
455
|
-
)
|
|
274
|
+
const e1 = await setWalker2(schema, {
|
|
275
|
+
$id: 'bl1',
|
|
276
|
+
number: { $decrement: 2 },
|
|
277
|
+
})
|
|
278
|
+
const e2 = await setWalker2(schema, {
|
|
279
|
+
$id: 'bl1',
|
|
280
|
+
number: { $decrement: 7 },
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
const res1 = await setWalker2(schema, {
|
|
284
|
+
$id: 'bl1',
|
|
285
|
+
number: { $decrement: 3 },
|
|
286
|
+
})
|
|
456
287
|
//exclusiveminmax
|
|
457
|
-
await
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
{
|
|
471
|
-
$id: 'bl1',
|
|
472
|
-
exclusiveminmax: { $decrement: 6 },
|
|
473
|
-
},
|
|
474
|
-
handlers
|
|
475
|
-
)
|
|
476
|
-
)
|
|
477
|
-
|
|
478
|
-
await setWalker(
|
|
479
|
-
schema,
|
|
480
|
-
{
|
|
481
|
-
$id: 'bl1',
|
|
482
|
-
exclusiveminmax: { $decrement: 4 },
|
|
483
|
-
},
|
|
484
|
-
handlers
|
|
485
|
-
)
|
|
288
|
+
const e3 = await setWalker2(schema, {
|
|
289
|
+
$id: 'bl1',
|
|
290
|
+
exclusiveminmax: { $decrement: 3 },
|
|
291
|
+
})
|
|
292
|
+
const e4 = await setWalker2(schema, {
|
|
293
|
+
$id: 'bl1',
|
|
294
|
+
exclusiveminmax: { $decrement: 6 },
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
const res2 = await setWalker2(schema, {
|
|
298
|
+
$id: 'bl1',
|
|
299
|
+
exclusiveminmax: { $decrement: 4 },
|
|
300
|
+
})
|
|
486
301
|
|
|
487
302
|
//integer
|
|
488
|
-
await
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
)
|
|
498
|
-
|
|
499
|
-
await setWalker(
|
|
500
|
-
schema,
|
|
501
|
-
{
|
|
502
|
-
$id: 'bl1',
|
|
503
|
-
integer: { $decrement: 3 },
|
|
504
|
-
},
|
|
505
|
-
handlers
|
|
506
|
-
)
|
|
303
|
+
const e5 = await setWalker2(schema, {
|
|
304
|
+
$id: 'bl1',
|
|
305
|
+
integer: { $decrement: 3.5 },
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
const res3 = await setWalker2(schema, {
|
|
309
|
+
$id: 'bl1',
|
|
310
|
+
integer: { $decrement: 3 },
|
|
311
|
+
})
|
|
507
312
|
//multiple of
|
|
508
313
|
|
|
509
|
-
await
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
schema,
|
|
522
|
-
{
|
|
523
|
-
$id: 'bl1',
|
|
524
|
-
multipleOf: { $decrement: 9 },
|
|
525
|
-
},
|
|
526
|
-
handlers
|
|
527
|
-
)
|
|
528
|
-
t.deepEqual(results, [
|
|
314
|
+
const e6 = await setWalker2(schema, {
|
|
315
|
+
$id: 'bl1',
|
|
316
|
+
multipleOf: { $decrement: 7 },
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
const res4 = await setWalker2(schema, {
|
|
320
|
+
$id: 'bl1',
|
|
321
|
+
multipleOf: { $decrement: 9 },
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
t.assert(errorCollect([e1, e2, e3, e4, e5, e6]).length > 0)
|
|
325
|
+
t.deepEqual(resultCollect([res1, res2, res3, res4]), [
|
|
529
326
|
{ path: ['number'], value: { $decrement: 3 } },
|
|
530
327
|
{ path: ['exclusiveminmax'], value: { $decrement: 4 } },
|
|
531
328
|
{ path: ['integer'], value: { $decrement: 3 } },
|
|
@@ -534,110 +331,59 @@ test('decrement', async (t) => {
|
|
|
534
331
|
})
|
|
535
332
|
|
|
536
333
|
test('increment', async (t) => {
|
|
537
|
-
const { handlers, results } = createHandlers()
|
|
538
334
|
//maxmin
|
|
539
|
-
await
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
{
|
|
553
|
-
$id: 'bl1',
|
|
554
|
-
number: { $increment: 7 },
|
|
555
|
-
},
|
|
556
|
-
handlers
|
|
557
|
-
)
|
|
558
|
-
)
|
|
559
|
-
|
|
560
|
-
await setWalker(
|
|
561
|
-
schema,
|
|
562
|
-
{
|
|
563
|
-
$id: 'bl1',
|
|
564
|
-
number: { $increment: 3 },
|
|
565
|
-
},
|
|
566
|
-
handlers
|
|
567
|
-
)
|
|
335
|
+
const e1 = await setWalker2(schema, {
|
|
336
|
+
$id: 'bl1',
|
|
337
|
+
number: { $increment: 2 },
|
|
338
|
+
})
|
|
339
|
+
const e2 = await setWalker2(schema, {
|
|
340
|
+
$id: 'bl1',
|
|
341
|
+
number: { $increment: 7 },
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
const res1 = await setWalker2(schema, {
|
|
345
|
+
$id: 'bl1',
|
|
346
|
+
number: { $increment: 3 },
|
|
347
|
+
})
|
|
568
348
|
//exclusiveminmax
|
|
569
|
-
await
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
{
|
|
583
|
-
$id: 'bl1',
|
|
584
|
-
exclusiveminmax: { $increment: 6 },
|
|
585
|
-
},
|
|
586
|
-
handlers
|
|
587
|
-
)
|
|
588
|
-
)
|
|
589
|
-
|
|
590
|
-
await setWalker(
|
|
591
|
-
schema,
|
|
592
|
-
{
|
|
593
|
-
$id: 'bl1',
|
|
594
|
-
exclusiveminmax: { $increment: 4 },
|
|
595
|
-
},
|
|
596
|
-
handlers
|
|
597
|
-
)
|
|
349
|
+
const e3 = await setWalker2(schema, {
|
|
350
|
+
$id: 'bl1',
|
|
351
|
+
exclusiveminmax: { $increment: 3 },
|
|
352
|
+
})
|
|
353
|
+
const e4 = await setWalker2(schema, {
|
|
354
|
+
$id: 'bl1',
|
|
355
|
+
exclusiveminmax: { $increment: 6 },
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
const res2 = await setWalker2(schema, {
|
|
359
|
+
$id: 'bl1',
|
|
360
|
+
exclusiveminmax: { $increment: 4 },
|
|
361
|
+
})
|
|
598
362
|
|
|
599
363
|
//integer
|
|
600
|
-
await
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
)
|
|
610
|
-
|
|
611
|
-
await setWalker(
|
|
612
|
-
schema,
|
|
613
|
-
{
|
|
614
|
-
$id: 'bl1',
|
|
615
|
-
integer: { $increment: 3 },
|
|
616
|
-
},
|
|
617
|
-
handlers
|
|
618
|
-
)
|
|
364
|
+
const e5 = await setWalker2(schema, {
|
|
365
|
+
$id: 'bl1',
|
|
366
|
+
integer: { $increment: 3.5 },
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
const res3 = await setWalker2(schema, {
|
|
370
|
+
$id: 'bl1',
|
|
371
|
+
integer: { $increment: 3 },
|
|
372
|
+
})
|
|
619
373
|
//multiple of
|
|
620
374
|
|
|
621
|
-
await
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
schema,
|
|
634
|
-
{
|
|
635
|
-
$id: 'bl1',
|
|
636
|
-
multipleOf: { $increment: 9 },
|
|
637
|
-
},
|
|
638
|
-
handlers
|
|
639
|
-
)
|
|
640
|
-
t.deepEqual(results, [
|
|
375
|
+
const e6 = await setWalker2(schema, {
|
|
376
|
+
$id: 'bl1',
|
|
377
|
+
multipleOf: { $increment: 7 },
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
const res4 = await setWalker2(schema, {
|
|
381
|
+
$id: 'bl1',
|
|
382
|
+
multipleOf: { $increment: 9 },
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
t.assert(errorCollect([e1, e2, e3, e4, e5, e6]).length > 0)
|
|
386
|
+
t.deepEqual(resultCollect([res1, res2, res3, res4]), [
|
|
641
387
|
{ path: ['number'], value: { $increment: 3 } },
|
|
642
388
|
{ path: ['exclusiveminmax'], value: { $increment: 4 } },
|
|
643
389
|
{ path: ['integer'], value: { $increment: 3 } },
|