@sanity/validation 3.0.0-dev-preview.10 → 3.0.0-dev-preview.13

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.
@@ -0,0 +1,336 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`array exact length constraint: exact length: too long 1`] = `
4
+ Array [
5
+ Object {
6
+ "item": ValidationError {
7
+ "children": undefined,
8
+ "message": "Must have exactly 2 items",
9
+ "operation": undefined,
10
+ "paths": Array [],
11
+ },
12
+ "level": "error",
13
+ "path": Array [],
14
+ },
15
+ ]
16
+ `;
17
+
18
+ exports[`array exact length constraint: exact length: too short 1`] = `
19
+ Array [
20
+ Object {
21
+ "item": ValidationError {
22
+ "children": undefined,
23
+ "message": "Must have exactly 2 items",
24
+ "operation": undefined,
25
+ "paths": Array [],
26
+ },
27
+ "level": "error",
28
+ "path": Array [],
29
+ },
30
+ ]
31
+ `;
32
+
33
+ exports[`array exact length constraint: exact length: valid 1`] = `Array []`;
34
+
35
+ exports[`array max length constraint: max length: too long 1`] = `
36
+ Array [
37
+ Object {
38
+ "item": ValidationError {
39
+ "children": undefined,
40
+ "message": "Must have at most 2 items",
41
+ "operation": undefined,
42
+ "paths": Array [],
43
+ },
44
+ "level": "error",
45
+ "path": Array [],
46
+ },
47
+ ]
48
+ `;
49
+
50
+ exports[`array max length constraint: max length: valid 1`] = `Array []`;
51
+
52
+ exports[`array min length constraint: min length: too short 1`] = `
53
+ Array [
54
+ Object {
55
+ "item": ValidationError {
56
+ "children": undefined,
57
+ "message": "Must have at least 2 items",
58
+ "operation": undefined,
59
+ "paths": Array [],
60
+ },
61
+ "level": "error",
62
+ "path": Array [],
63
+ },
64
+ ]
65
+ `;
66
+
67
+ exports[`array min length constraint: min length: valid 1`] = `Array []`;
68
+
69
+ exports[`array required constraint: required: empty array 1`] = `Array []`;
70
+
71
+ exports[`array required constraint: required: null 1`] = `
72
+ Array [
73
+ Object {
74
+ "item": ValidationError {
75
+ "children": undefined,
76
+ "message": "Expected type \\"Array\\", got \\"null\\"",
77
+ "operation": undefined,
78
+ "paths": Array [],
79
+ },
80
+ "level": "error",
81
+ "path": Array [],
82
+ },
83
+ Object {
84
+ "item": ValidationError {
85
+ "children": undefined,
86
+ "message": "Required",
87
+ "operation": undefined,
88
+ "paths": Array [],
89
+ },
90
+ "level": "error",
91
+ "path": Array [],
92
+ },
93
+ ]
94
+ `;
95
+
96
+ exports[`array required constraint: required: undefined 1`] = `
97
+ Array [
98
+ Object {
99
+ "item": ValidationError {
100
+ "children": undefined,
101
+ "message": "Required",
102
+ "operation": undefined,
103
+ "paths": Array [],
104
+ },
105
+ "level": "error",
106
+ "path": Array [],
107
+ },
108
+ ]
109
+ `;
110
+
111
+ exports[`array required constraint: required: valid 1`] = `Array []`;
112
+
113
+ exports[`array unique constraint (default, array values): array unique: duplicates 1`] = `
114
+ Array [
115
+ Object {
116
+ "item": ValidationError {
117
+ "children": undefined,
118
+ "message": "Can't be a duplicate",
119
+ "operation": undefined,
120
+ "paths": Array [
121
+ Array [
122
+ 0,
123
+ ],
124
+ Array [
125
+ 1,
126
+ ],
127
+ ],
128
+ },
129
+ "level": "error",
130
+ "path": Array [
131
+ 0,
132
+ ],
133
+ },
134
+ Object {
135
+ "item": ValidationError {
136
+ "children": undefined,
137
+ "message": "Can't be a duplicate",
138
+ "operation": undefined,
139
+ "paths": Array [
140
+ Array [
141
+ 0,
142
+ ],
143
+ Array [
144
+ 1,
145
+ ],
146
+ ],
147
+ },
148
+ "level": "error",
149
+ "path": Array [
150
+ 1,
151
+ ],
152
+ },
153
+ ]
154
+ `;
155
+
156
+ exports[`array unique constraint (default, array values): array unique: valid 1`] = `Array []`;
157
+
158
+ exports[`array unique constraint (default, bool values): boolean unique: duplicates 1`] = `
159
+ Array [
160
+ Object {
161
+ "item": ValidationError {
162
+ "children": undefined,
163
+ "message": "Can't be a duplicate",
164
+ "operation": undefined,
165
+ "paths": Array [
166
+ Array [
167
+ 0,
168
+ ],
169
+ Array [
170
+ 2,
171
+ ],
172
+ ],
173
+ },
174
+ "level": "error",
175
+ "path": Array [
176
+ 0,
177
+ ],
178
+ },
179
+ Object {
180
+ "item": ValidationError {
181
+ "children": undefined,
182
+ "message": "Can't be a duplicate",
183
+ "operation": undefined,
184
+ "paths": Array [
185
+ Array [
186
+ 0,
187
+ ],
188
+ Array [
189
+ 2,
190
+ ],
191
+ ],
192
+ },
193
+ "level": "error",
194
+ "path": Array [
195
+ 2,
196
+ ],
197
+ },
198
+ ]
199
+ `;
200
+
201
+ exports[`array unique constraint (default, bool values): boolean unique: valid 1`] = `Array []`;
202
+
203
+ exports[`array unique constraint (default, numeric values): numeric unique: duplicates 1`] = `
204
+ Array [
205
+ Object {
206
+ "item": ValidationError {
207
+ "children": undefined,
208
+ "message": "Can't be a duplicate",
209
+ "operation": undefined,
210
+ "paths": Array [
211
+ Array [
212
+ 0,
213
+ ],
214
+ Array [
215
+ 2,
216
+ ],
217
+ ],
218
+ },
219
+ "level": "error",
220
+ "path": Array [
221
+ 0,
222
+ ],
223
+ },
224
+ Object {
225
+ "item": ValidationError {
226
+ "children": undefined,
227
+ "message": "Can't be a duplicate",
228
+ "operation": undefined,
229
+ "paths": Array [
230
+ Array [
231
+ 0,
232
+ ],
233
+ Array [
234
+ 2,
235
+ ],
236
+ ],
237
+ },
238
+ "level": "error",
239
+ "path": Array [
240
+ 2,
241
+ ],
242
+ },
243
+ ]
244
+ `;
245
+
246
+ exports[`array unique constraint (default, numeric values): numeric unique: valid 1`] = `Array []`;
247
+
248
+ exports[`array unique constraint (default, object values): object unique: duplicates 1`] = `
249
+ Array [
250
+ Object {
251
+ "item": ValidationError {
252
+ "children": undefined,
253
+ "message": "Can't be a duplicate",
254
+ "operation": undefined,
255
+ "paths": Array [
256
+ Array [
257
+ 0,
258
+ ],
259
+ Array [
260
+ 3,
261
+ ],
262
+ ],
263
+ },
264
+ "level": "error",
265
+ "path": Array [
266
+ 0,
267
+ ],
268
+ },
269
+ Object {
270
+ "item": ValidationError {
271
+ "children": undefined,
272
+ "message": "Can't be a duplicate",
273
+ "operation": undefined,
274
+ "paths": Array [
275
+ Array [
276
+ 0,
277
+ ],
278
+ Array [
279
+ 3,
280
+ ],
281
+ ],
282
+ },
283
+ "level": "error",
284
+ "path": Array [
285
+ 3,
286
+ ],
287
+ },
288
+ ]
289
+ `;
290
+
291
+ exports[`array unique constraint (default, object values): object unique: valid 1`] = `Array []`;
292
+
293
+ exports[`array unique constraint (default, simple values): simple unique: duplicates 1`] = `
294
+ Array [
295
+ Object {
296
+ "item": ValidationError {
297
+ "children": undefined,
298
+ "message": "Can't be a duplicate",
299
+ "operation": undefined,
300
+ "paths": Array [
301
+ Array [
302
+ 0,
303
+ ],
304
+ Array [
305
+ 3,
306
+ ],
307
+ ],
308
+ },
309
+ "level": "error",
310
+ "path": Array [
311
+ 0,
312
+ ],
313
+ },
314
+ Object {
315
+ "item": ValidationError {
316
+ "children": undefined,
317
+ "message": "Can't be a duplicate",
318
+ "operation": undefined,
319
+ "paths": Array [
320
+ Array [
321
+ 0,
322
+ ],
323
+ Array [
324
+ 3,
325
+ ],
326
+ ],
327
+ },
328
+ "level": "error",
329
+ "path": Array [
330
+ 3,
331
+ ],
332
+ },
333
+ ]
334
+ `;
335
+
336
+ exports[`array unique constraint (default, simple values): simple unique: valid 1`] = `Array []`;
@@ -0,0 +1,253 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`child rules all() rules - multiple failures: all() rules - match 1`] = `Array []`;
4
+
5
+ exports[`child rules all() rules - multiple failures: all() rules - multiple failures, custom messages 1`] = `
6
+ Array [
7
+ Object {
8
+ "item": ValidationError {
9
+ "children": Array [
10
+ Object {
11
+ "item": ValidationError {
12
+ "children": undefined,
13
+ "message": "Must start with an uppercase character",
14
+ "operation": undefined,
15
+ "paths": Array [],
16
+ },
17
+ "level": "error",
18
+ "path": Array [],
19
+ },
20
+ Object {
21
+ "item": ValidationError {
22
+ "children": undefined,
23
+ "message": "5 chars or more",
24
+ "operation": undefined,
25
+ "paths": Array [],
26
+ },
27
+ "level": "error",
28
+ "path": Array [],
29
+ },
30
+ ],
31
+ "message": "[Must start with an uppercase character - AND - 5 chars or more]",
32
+ "operation": "AND",
33
+ "paths": Array [],
34
+ },
35
+ "level": "error",
36
+ "path": Array [],
37
+ },
38
+ ]
39
+ `;
40
+
41
+ exports[`child rules all() rules - single failure, custom, common error: all() rules - multiple failures, common error 1`] = `
42
+ Array [
43
+ Object {
44
+ "item": ValidationError {
45
+ "children": Array [
46
+ Object {
47
+ "item": ValidationError {
48
+ "children": undefined,
49
+ "message": "Does not match \\"/^[A-Z]/\\"-pattern",
50
+ "operation": undefined,
51
+ "paths": Array [],
52
+ },
53
+ "level": "error",
54
+ "path": Array [],
55
+ },
56
+ Object {
57
+ "item": ValidationError {
58
+ "children": undefined,
59
+ "message": "Must be at least 5 characters long",
60
+ "operation": undefined,
61
+ "paths": Array [],
62
+ },
63
+ "level": "error",
64
+ "path": Array [],
65
+ },
66
+ ],
67
+ "message": "Needs to be a capital letter followed by at least 4 lowercase characters",
68
+ "operation": "AND",
69
+ "paths": Array [],
70
+ },
71
+ "level": "error",
72
+ "path": Array [],
73
+ },
74
+ ]
75
+ `;
76
+
77
+ exports[`child rules all() rules - single failure, custom, common error: all() rules - single failure, common error 1`] = `
78
+ Array [
79
+ Object {
80
+ "item": ValidationError {
81
+ "children": undefined,
82
+ "message": "Needs to start with a capital letter and then follow with lowercase characters",
83
+ "operation": "AND",
84
+ "paths": Array [],
85
+ },
86
+ "level": "error",
87
+ "path": Array [],
88
+ },
89
+ ]
90
+ `;
91
+
92
+ exports[`child rules all() rules - single failure: all() rules - match 1`] = `Array []`;
93
+
94
+ exports[`child rules all() rules - single failure: all() rules - single failure, custom message 1`] = `
95
+ Array [
96
+ Object {
97
+ "item": ValidationError {
98
+ "children": undefined,
99
+ "message": "Must start with an uppercase character",
100
+ "operation": "AND",
101
+ "paths": Array [],
102
+ },
103
+ "level": "error",
104
+ "path": Array [],
105
+ },
106
+ ]
107
+ `;
108
+
109
+ exports[`child rules either() rules - all fail, custom, common error: either() rules - all fail, common error 1`] = `
110
+ Array [
111
+ Object {
112
+ "item": ValidationError {
113
+ "children": Array [
114
+ Object {
115
+ "item": ValidationError {
116
+ "children": undefined,
117
+ "message": "Does not match \\"/^[A-Z]/\\"-pattern",
118
+ "operation": undefined,
119
+ "paths": Array [],
120
+ },
121
+ "level": "error",
122
+ "path": Array [],
123
+ },
124
+ Object {
125
+ "item": ValidationError {
126
+ "children": undefined,
127
+ "message": "Does not match \\"/^i[A-Z]/\\"-pattern",
128
+ "operation": undefined,
129
+ "paths": Array [],
130
+ },
131
+ "level": "error",
132
+ "path": Array [],
133
+ },
134
+ ],
135
+ "message": "Needs to start with a capital letter, unless it's an iProduct",
136
+ "operation": "OR",
137
+ "paths": Array [],
138
+ },
139
+ "level": "error",
140
+ "path": Array [],
141
+ },
142
+ ]
143
+ `;
144
+
145
+ exports[`child rules either() rules - all matches: either() rules - all match 1`] = `Array []`;
146
+
147
+ exports[`child rules either() rules - all matches: either() rules - no matches 1`] = `
148
+ Array [
149
+ Object {
150
+ "item": ValidationError {
151
+ "children": Array [
152
+ Object {
153
+ "item": ValidationError {
154
+ "children": undefined,
155
+ "message": "Must start with a capital R",
156
+ "operation": undefined,
157
+ "paths": Array [],
158
+ },
159
+ "level": "error",
160
+ "path": Array [],
161
+ },
162
+ Object {
163
+ "item": ValidationError {
164
+ "children": undefined,
165
+ "message": "Must end with \\"ed\\"",
166
+ "operation": undefined,
167
+ "paths": Array [],
168
+ },
169
+ "level": "error",
170
+ "path": Array [],
171
+ },
172
+ ],
173
+ "message": "[Must start with a capital R - OR - Must end with \\"ed\\"]",
174
+ "operation": "OR",
175
+ "paths": Array [],
176
+ },
177
+ "level": "error",
178
+ "path": Array [],
179
+ },
180
+ ]
181
+ `;
182
+
183
+ exports[`child rules either() rules - single failure: either() rules - match 1`] = `
184
+ Array [
185
+ Object {
186
+ "item": ValidationError {
187
+ "children": Array [
188
+ Object {
189
+ "item": ValidationError {
190
+ "children": undefined,
191
+ "message": "Must be rgb(num, num, num) format",
192
+ "operation": undefined,
193
+ "paths": Array [],
194
+ },
195
+ "level": "error",
196
+ "path": Array [],
197
+ },
198
+ Object {
199
+ "item": ValidationError {
200
+ "children": undefined,
201
+ "message": "Must be hex color with #-prefix",
202
+ "operation": undefined,
203
+ "paths": Array [],
204
+ },
205
+ "level": "error",
206
+ "path": Array [],
207
+ },
208
+ ],
209
+ "message": "[Must be rgb(num, num, num) format - OR - Must be hex color with #-prefix]",
210
+ "operation": "OR",
211
+ "paths": Array [],
212
+ },
213
+ "level": "error",
214
+ "path": Array [],
215
+ },
216
+ ]
217
+ `;
218
+
219
+ exports[`child rules either() rules - single failure: either() rules - single failure, custom message 1`] = `
220
+ Array [
221
+ Object {
222
+ "item": ValidationError {
223
+ "children": Array [
224
+ Object {
225
+ "item": ValidationError {
226
+ "children": undefined,
227
+ "message": "Must be rgb(num, num, num) format",
228
+ "operation": undefined,
229
+ "paths": Array [],
230
+ },
231
+ "level": "error",
232
+ "path": Array [],
233
+ },
234
+ Object {
235
+ "item": ValidationError {
236
+ "children": undefined,
237
+ "message": "Must be hex color with #-prefix",
238
+ "operation": undefined,
239
+ "paths": Array [],
240
+ },
241
+ "level": "error",
242
+ "path": Array [],
243
+ },
244
+ ],
245
+ "message": "[Must be rgb(num, num, num) format - OR - Must be hex color with #-prefix]",
246
+ "operation": "OR",
247
+ "paths": Array [],
248
+ },
249
+ "level": "error",
250
+ "path": Array [],
251
+ },
252
+ ]
253
+ `;
@@ -0,0 +1,91 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`generics can customize error messages 1`] = `
4
+ Array [
5
+ Object {
6
+ "item": ValidationError {
7
+ "children": undefined,
8
+ "message": "Dude it needs to be a string",
9
+ "operation": undefined,
10
+ "paths": Array [],
11
+ },
12
+ "level": "error",
13
+ "path": Array [],
14
+ },
15
+ ]
16
+ `;
17
+
18
+ exports[`generics can customize info messages 1`] = `
19
+ Array [
20
+ Object {
21
+ "item": ValidationError {
22
+ "children": undefined,
23
+ "message": "Dude it should probably be a string",
24
+ "operation": undefined,
25
+ "paths": Array [],
26
+ },
27
+ "level": "info",
28
+ "path": Array [],
29
+ },
30
+ ]
31
+ `;
32
+
33
+ exports[`generics can customize warning messages 1`] = `
34
+ Array [
35
+ Object {
36
+ "item": ValidationError {
37
+ "children": undefined,
38
+ "message": "Dude it should probably be a string",
39
+ "operation": undefined,
40
+ "paths": Array [],
41
+ },
42
+ "level": "warning",
43
+ "path": Array [],
44
+ },
45
+ ]
46
+ `;
47
+
48
+ exports[`generics can demote errors to warnings 1`] = `
49
+ Array [
50
+ Object {
51
+ "item": ValidationError {
52
+ "children": undefined,
53
+ "message": "Expected type \\"String\\", got \\"Number\\"",
54
+ "operation": undefined,
55
+ "paths": Array [],
56
+ },
57
+ "level": "warning",
58
+ "path": Array [],
59
+ },
60
+ ]
61
+ `;
62
+
63
+ exports[`generics can merge rules 1`] = `
64
+ Array [
65
+ Object {
66
+ "item": ValidationError {
67
+ "children": undefined,
68
+ "message": "Must be at least 5 characters long",
69
+ "operation": undefined,
70
+ "paths": Array [],
71
+ },
72
+ "level": "error",
73
+ "path": Array [],
74
+ },
75
+ ]
76
+ `;
77
+
78
+ exports[`generics returns arrays of errors/warnings by default 1`] = `
79
+ Array [
80
+ Object {
81
+ "item": ValidationError {
82
+ "children": undefined,
83
+ "message": "Expected type \\"String\\", got \\"Number\\"",
84
+ "operation": undefined,
85
+ "paths": Array [],
86
+ },
87
+ "level": "error",
88
+ "path": Array [],
89
+ },
90
+ ]
91
+ `;