@learncard/react 2.3.52 → 2.3.54
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/base.css +1 -1
- package/dist/base.js +1 -1
- package/dist/cjs/AchievementCard-0123be96.js.map +1 -1
- package/dist/cjs/Button-a7af702b.js.map +1 -1
- package/dist/cjs/CircleCheckButton-97c4f608.js.map +1 -1
- package/dist/cjs/CircleIcon-41b3fa88.js.map +1 -1
- package/dist/cjs/CircleSpinner-093cce04.js.map +1 -1
- package/dist/cjs/CourseCard-338a32ee.js.map +1 -1
- package/dist/cjs/CourseVerticalCard-ba8fc2f7.js.map +1 -1
- package/dist/cjs/FlippyCard-33e03a9e.js.map +1 -1
- package/dist/cjs/GenericArrow-8dfb261d.js.map +1 -1
- package/dist/cjs/GenericCard-c5b70b29.js.map +1 -1
- package/dist/cjs/JobHistoryCard-05a3f98b.js.map +1 -1
- package/dist/cjs/JobListCard-e2b3c042.js.map +1 -1
- package/dist/cjs/LearnCardCreditCardBackFace-87cc8b9f.js.map +1 -1
- package/dist/cjs/LearnCardCreditCardFrontFace-4452fd7a.js.map +1 -1
- package/dist/cjs/LearnPill-23ff7225.js.map +1 -1
- package/dist/cjs/MiniVCThumbnail-a78e44f2.js.map +1 -1
- package/dist/cjs/Notification-10b40c07.js.map +1 -1
- package/dist/cjs/QRCodeCard-efaa58e1.js.map +1 -1
- package/dist/cjs/RoundedPill-15c0aca9.js.map +1 -1
- package/dist/cjs/SchoolIDCard-1baf77e8.js.map +1 -1
- package/dist/cjs/SkillTabCard-82f2fae0.js.map +1 -1
- package/dist/cjs/SkillVerticalCard-3eb3a8e9.js.map +1 -1
- package/dist/cjs/SkillsCard-4b6dbb4f.js.map +1 -1
- package/dist/cjs/SkillsStatsCard-97a35a88.js.map +1 -1
- package/dist/cjs/SmallAchievementCard-c76701ce.js.map +1 -1
- package/dist/cjs/Trophy-9ede7f2b.js.map +1 -1
- package/dist/cjs/User-b16d5499.js.map +1 -1
- package/dist/cjs/{VCCard-d04bbb8d.js → VCCard-d12310c5.js} +2 -2
- package/dist/cjs/VCCard-d12310c5.js.map +1 -0
- package/dist/cjs/{VCDisplayBackFace-80deea80.js → VCDisplayBackFace-88beca2a.js} +2 -2
- package/dist/{esm/VCDisplayBackFace-fabc926c.js.map → cjs/VCDisplayBackFace-88beca2a.js.map} +1 -1
- package/dist/cjs/VCDisplayCard-2444fe1b.js +5837 -0
- package/dist/cjs/VCDisplayCard-2444fe1b.js.map +1 -0
- package/dist/cjs/VCThumbnail-6bf86bb2.js.map +1 -1
- package/dist/cjs/VCVerificationCheck-0e495524.js.map +1 -1
- package/dist/cjs/{VCVerificationPill-656a2742.js → VCVerificationPill-e1b817ac.js} +260 -76
- package/dist/cjs/VCVerificationPill-e1b817ac.js.map +1 -0
- package/dist/cjs/constants-678d0aa9.js.map +1 -1
- package/dist/cjs/icons-cf98ef88.js.map +1 -1
- package/dist/cjs/index-63ee021e.js.map +1 -1
- package/dist/cjs/index-6cab6d37.js.map +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index10.js +4 -4
- package/dist/cjs/index29.js +4 -4
- package/dist/cjs/index30.js +2 -2
- package/dist/cjs/index31.js +3 -3
- package/dist/cjs/index35.js +1 -1
- package/dist/esm/AchievementCard-92b5a3ea.js.map +1 -1
- package/dist/esm/Button-5f805204.js.map +1 -1
- package/dist/esm/CircleCheckButton-a55dfd2a.js.map +1 -1
- package/dist/esm/CircleIcon-b0dca4b6.js.map +1 -1
- package/dist/esm/CircleSpinner-9b8b1a6b.js.map +1 -1
- package/dist/esm/CourseCard-663ff174.js.map +1 -1
- package/dist/esm/CourseVerticalCard-643f767b.js.map +1 -1
- package/dist/esm/FlippyCard-682649d7.js.map +1 -1
- package/dist/esm/GenericArrow-0dba1707.js.map +1 -1
- package/dist/esm/GenericCard-ada539c7.js.map +1 -1
- package/dist/esm/JobHistoryCard-80d4ef27.js.map +1 -1
- package/dist/esm/JobListCard-e84e21e7.js.map +1 -1
- package/dist/esm/LearnCardCreditCardBackFace-9baa9e6b.js.map +1 -1
- package/dist/esm/LearnCardCreditCardFrontFace-cf793917.js.map +1 -1
- package/dist/esm/LearnPill-a1001ae7.js.map +1 -1
- package/dist/esm/MiniVCThumbnail-6a07e810.js.map +1 -1
- package/dist/esm/Notification-ac50790d.js.map +1 -1
- package/dist/esm/QRCodeCard-c57e2067.js.map +1 -1
- package/dist/esm/RoundedPill-2f4dc646.js.map +1 -1
- package/dist/esm/SchoolIDCard-3b746226.js.map +1 -1
- package/dist/esm/SkillTabCard-ade7a48c.js.map +1 -1
- package/dist/esm/SkillVerticalCard-108f49bb.js.map +1 -1
- package/dist/esm/SkillsCard-92a51db2.js.map +1 -1
- package/dist/esm/SkillsStatsCard-1628fe9c.js.map +1 -1
- package/dist/esm/SmallAchievementCard-2d87ac82.js.map +1 -1
- package/dist/esm/Trophy-702610b8.js.map +1 -1
- package/dist/esm/User-d3aa7eb3.js.map +1 -1
- package/dist/esm/{VCCard-fdbb9b04.js → VCCard-490ef20e.js} +2 -2
- package/dist/esm/VCCard-490ef20e.js.map +1 -0
- package/dist/esm/{VCDisplayBackFace-fabc926c.js → VCDisplayBackFace-2f04590a.js} +2 -2
- package/dist/{cjs/VCDisplayBackFace-80deea80.js.map → esm/VCDisplayBackFace-2f04590a.js.map} +1 -1
- package/dist/esm/VCDisplayCard-5597d354.js +5828 -0
- package/dist/esm/VCDisplayCard-5597d354.js.map +1 -0
- package/dist/esm/VCThumbnail-3c254bda.js.map +1 -1
- package/dist/esm/VCVerificationCheck-b2de0477.js.map +1 -1
- package/dist/esm/{VCVerificationPill-26519af1.js → VCVerificationPill-09889426.js} +260 -76
- package/dist/esm/VCVerificationPill-09889426.js.map +1 -0
- package/dist/esm/constants-e0d87a29.js.map +1 -1
- package/dist/esm/icons-10f38bbd.js.map +1 -1
- package/dist/esm/index-15b828c0.js.map +1 -1
- package/dist/esm/index-2ef79548.js.map +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/index10.js +4 -4
- package/dist/esm/index29.js +4 -4
- package/dist/esm/index30.js +2 -2
- package/dist/esm/index31.js +3 -3
- package/dist/esm/index35.js +1 -1
- package/dist/main.css +1 -1
- package/dist/main.js +1 -1
- package/package.json +3 -3
- package/dist/cjs/VCCard-d04bbb8d.js.map +0 -1
- package/dist/cjs/VCDisplayCard-8af36d1c.js +0 -2586
- package/dist/cjs/VCDisplayCard-8af36d1c.js.map +0 -1
- package/dist/cjs/VCVerificationPill-656a2742.js.map +0 -1
- package/dist/esm/VCCard-fdbb9b04.js.map +0 -1
- package/dist/esm/VCDisplayCard-df6c485d.js +0 -2577
- package/dist/esm/VCDisplayCard-df6c485d.js.map +0 -1
- package/dist/esm/VCVerificationPill-26519af1.js.map +0 -1
|
@@ -14,6 +14,9 @@ var VerificationWarningIcon__default = /*#__PURE__*/_interopDefaultLegacy(Verifi
|
|
|
14
14
|
|
|
15
15
|
var util;
|
|
16
16
|
(function (util) {
|
|
17
|
+
util.assertEqual = (val) => val;
|
|
18
|
+
function assertIs(_arg) { }
|
|
19
|
+
util.assertIs = assertIs;
|
|
17
20
|
function assertNever(_x) {
|
|
18
21
|
throw new Error();
|
|
19
22
|
}
|
|
@@ -65,6 +68,12 @@ var util;
|
|
|
65
68
|
.join(separator);
|
|
66
69
|
}
|
|
67
70
|
util.joinValues = joinValues;
|
|
71
|
+
util.jsonStringifyReplacer = (_, value) => {
|
|
72
|
+
if (typeof value === "bigint") {
|
|
73
|
+
return value.toString();
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
};
|
|
68
77
|
})(util || (util = {}));
|
|
69
78
|
const ZodParsedType = util.arrayToEnum([
|
|
70
79
|
"string",
|
|
@@ -229,7 +238,7 @@ class ZodError extends Error {
|
|
|
229
238
|
return this.message;
|
|
230
239
|
}
|
|
231
240
|
get message() {
|
|
232
|
-
return JSON.stringify(this.issues,
|
|
241
|
+
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
233
242
|
}
|
|
234
243
|
get isEmpty() {
|
|
235
244
|
return this.issues.length === 0;
|
|
@@ -256,7 +265,8 @@ ZodError.create = (issues) => {
|
|
|
256
265
|
const error = new ZodError(issues);
|
|
257
266
|
return error;
|
|
258
267
|
};
|
|
259
|
-
|
|
268
|
+
|
|
269
|
+
const errorMap = (issue, _ctx) => {
|
|
260
270
|
let message;
|
|
261
271
|
switch (issue.code) {
|
|
262
272
|
case ZodIssueCode.invalid_type:
|
|
@@ -268,7 +278,7 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
268
278
|
}
|
|
269
279
|
break;
|
|
270
280
|
case ZodIssueCode.invalid_literal:
|
|
271
|
-
message = `Invalid literal value, expected ${JSON.stringify(issue.expected)}`;
|
|
281
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
272
282
|
break;
|
|
273
283
|
case ZodIssueCode.unrecognized_keys:
|
|
274
284
|
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
@@ -292,10 +302,23 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
292
302
|
message = `Invalid date`;
|
|
293
303
|
break;
|
|
294
304
|
case ZodIssueCode.invalid_string:
|
|
295
|
-
if (issue.validation
|
|
305
|
+
if (typeof issue.validation === "object") {
|
|
306
|
+
if ("startsWith" in issue.validation) {
|
|
307
|
+
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
308
|
+
}
|
|
309
|
+
else if ("endsWith" in issue.validation) {
|
|
310
|
+
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
util.assertNever(issue.validation);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else if (issue.validation !== "regex") {
|
|
296
317
|
message = `Invalid ${issue.validation}`;
|
|
297
|
-
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
298
320
|
message = "Invalid";
|
|
321
|
+
}
|
|
299
322
|
break;
|
|
300
323
|
case ZodIssueCode.too_small:
|
|
301
324
|
if (issue.type === "array")
|
|
@@ -304,6 +327,8 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
304
327
|
message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
305
328
|
else if (issue.type === "number")
|
|
306
329
|
message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
|
|
330
|
+
else if (issue.type === "date")
|
|
331
|
+
message = `Date must be greater than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.minimum)}`;
|
|
307
332
|
else
|
|
308
333
|
message = "Invalid input";
|
|
309
334
|
break;
|
|
@@ -314,6 +339,8 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
314
339
|
message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
315
340
|
else if (issue.type === "number")
|
|
316
341
|
message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
|
|
342
|
+
else if (issue.type === "date")
|
|
343
|
+
message = `Date must be smaller than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.maximum)}`;
|
|
317
344
|
else
|
|
318
345
|
message = "Invalid input";
|
|
319
346
|
break;
|
|
@@ -332,10 +359,14 @@ const defaultErrorMap = (issue, _ctx) => {
|
|
|
332
359
|
}
|
|
333
360
|
return { message };
|
|
334
361
|
};
|
|
335
|
-
|
|
336
|
-
|
|
362
|
+
|
|
363
|
+
let overrideErrorMap = errorMap;
|
|
364
|
+
function setErrorMap(map) {
|
|
337
365
|
overrideErrorMap = map;
|
|
338
|
-
}
|
|
366
|
+
}
|
|
367
|
+
function getErrorMap() {
|
|
368
|
+
return overrideErrorMap;
|
|
369
|
+
}
|
|
339
370
|
|
|
340
371
|
const makeIssue = (params) => {
|
|
341
372
|
const { data, path, errorMaps, issueData } = params;
|
|
@@ -367,8 +398,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
367
398
|
errorMaps: [
|
|
368
399
|
ctx.common.contextualErrorMap,
|
|
369
400
|
ctx.schemaErrorMap,
|
|
370
|
-
|
|
371
|
-
|
|
401
|
+
getErrorMap(),
|
|
402
|
+
errorMap,
|
|
372
403
|
].filter((x) => !!x),
|
|
373
404
|
});
|
|
374
405
|
ctx.common.issues.push(issue);
|
|
@@ -469,18 +500,17 @@ function processCreateParams(params) {
|
|
|
469
500
|
return {};
|
|
470
501
|
const { errorMap, invalid_type_error, required_error, description } = params;
|
|
471
502
|
if (errorMap && (invalid_type_error || required_error)) {
|
|
472
|
-
throw new Error(`Can't use "
|
|
503
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
473
504
|
}
|
|
474
505
|
if (errorMap)
|
|
475
506
|
return { errorMap: errorMap, description };
|
|
476
507
|
const customMap = (iss, ctx) => {
|
|
477
508
|
if (iss.code !== "invalid_type")
|
|
478
509
|
return { message: ctx.defaultError };
|
|
479
|
-
if (typeof ctx.data === "undefined"
|
|
480
|
-
return { message: required_error };
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return { message: ctx.defaultError };
|
|
510
|
+
if (typeof ctx.data === "undefined") {
|
|
511
|
+
return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
|
|
512
|
+
}
|
|
513
|
+
return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
|
|
484
514
|
};
|
|
485
515
|
return { errorMap: customMap, description };
|
|
486
516
|
}
|
|
@@ -693,6 +723,13 @@ class ZodType {
|
|
|
693
723
|
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
694
724
|
});
|
|
695
725
|
}
|
|
726
|
+
brand() {
|
|
727
|
+
return new ZodBranded({
|
|
728
|
+
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
729
|
+
type: this,
|
|
730
|
+
...processCreateParams(undefined),
|
|
731
|
+
});
|
|
732
|
+
}
|
|
696
733
|
describe(description) {
|
|
697
734
|
const This = this.constructor;
|
|
698
735
|
return new This({
|
|
@@ -837,6 +874,28 @@ class ZodString extends ZodType {
|
|
|
837
874
|
else if (check.kind === "trim") {
|
|
838
875
|
input.data = input.data.trim();
|
|
839
876
|
}
|
|
877
|
+
else if (check.kind === "startsWith") {
|
|
878
|
+
if (!input.data.startsWith(check.value)) {
|
|
879
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
880
|
+
addIssueToContext(ctx, {
|
|
881
|
+
code: ZodIssueCode.invalid_string,
|
|
882
|
+
validation: { startsWith: check.value },
|
|
883
|
+
message: check.message,
|
|
884
|
+
});
|
|
885
|
+
status.dirty();
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
else if (check.kind === "endsWith") {
|
|
889
|
+
if (!input.data.endsWith(check.value)) {
|
|
890
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
891
|
+
addIssueToContext(ctx, {
|
|
892
|
+
code: ZodIssueCode.invalid_string,
|
|
893
|
+
validation: { endsWith: check.value },
|
|
894
|
+
message: check.message,
|
|
895
|
+
});
|
|
896
|
+
status.dirty();
|
|
897
|
+
}
|
|
898
|
+
}
|
|
840
899
|
else {
|
|
841
900
|
util.assertNever(check);
|
|
842
901
|
}
|
|
@@ -868,6 +927,20 @@ class ZodString extends ZodType {
|
|
|
868
927
|
...errorUtil.errToObj(message),
|
|
869
928
|
});
|
|
870
929
|
}
|
|
930
|
+
startsWith(value, message) {
|
|
931
|
+
return this._addCheck({
|
|
932
|
+
kind: "startsWith",
|
|
933
|
+
value: value,
|
|
934
|
+
...errorUtil.errToObj(message),
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
endsWith(value, message) {
|
|
938
|
+
return this._addCheck({
|
|
939
|
+
kind: "endsWith",
|
|
940
|
+
value: value,
|
|
941
|
+
...errorUtil.errToObj(message),
|
|
942
|
+
});
|
|
943
|
+
}
|
|
871
944
|
min(minLength, message) {
|
|
872
945
|
return this._addCheck({
|
|
873
946
|
kind: "min",
|
|
@@ -898,25 +971,23 @@ class ZodString extends ZodType {
|
|
|
898
971
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
899
972
|
}
|
|
900
973
|
get minLength() {
|
|
901
|
-
let min =
|
|
902
|
-
this._def.checks
|
|
974
|
+
let min = null;
|
|
975
|
+
for (const ch of this._def.checks) {
|
|
903
976
|
if (ch.kind === "min") {
|
|
904
|
-
if (min === null || ch.value > min)
|
|
977
|
+
if (min === null || ch.value > min)
|
|
905
978
|
min = ch.value;
|
|
906
|
-
}
|
|
907
979
|
}
|
|
908
|
-
}
|
|
980
|
+
}
|
|
909
981
|
return min;
|
|
910
982
|
}
|
|
911
983
|
get maxLength() {
|
|
912
984
|
let max = null;
|
|
913
|
-
this._def.checks
|
|
985
|
+
for (const ch of this._def.checks) {
|
|
914
986
|
if (ch.kind === "max") {
|
|
915
|
-
if (max === null || ch.value < max)
|
|
987
|
+
if (max === null || ch.value < max)
|
|
916
988
|
max = ch.value;
|
|
917
|
-
}
|
|
918
989
|
}
|
|
919
|
-
}
|
|
990
|
+
}
|
|
920
991
|
return max;
|
|
921
992
|
}
|
|
922
993
|
}
|
|
@@ -1187,14 +1258,88 @@ class ZodDate extends ZodType {
|
|
|
1187
1258
|
});
|
|
1188
1259
|
return INVALID;
|
|
1189
1260
|
}
|
|
1261
|
+
const status = new ParseStatus();
|
|
1262
|
+
let ctx = undefined;
|
|
1263
|
+
for (const check of this._def.checks) {
|
|
1264
|
+
if (check.kind === "min") {
|
|
1265
|
+
if (input.data.getTime() < check.value) {
|
|
1266
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1267
|
+
addIssueToContext(ctx, {
|
|
1268
|
+
code: ZodIssueCode.too_small,
|
|
1269
|
+
message: check.message,
|
|
1270
|
+
inclusive: true,
|
|
1271
|
+
minimum: check.value,
|
|
1272
|
+
type: "date",
|
|
1273
|
+
});
|
|
1274
|
+
status.dirty();
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
else if (check.kind === "max") {
|
|
1278
|
+
if (input.data.getTime() > check.value) {
|
|
1279
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1280
|
+
addIssueToContext(ctx, {
|
|
1281
|
+
code: ZodIssueCode.too_big,
|
|
1282
|
+
message: check.message,
|
|
1283
|
+
inclusive: true,
|
|
1284
|
+
maximum: check.value,
|
|
1285
|
+
type: "date",
|
|
1286
|
+
});
|
|
1287
|
+
status.dirty();
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
util.assertNever(check);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1190
1294
|
return {
|
|
1191
|
-
status:
|
|
1295
|
+
status: status.value,
|
|
1192
1296
|
value: new Date(input.data.getTime()),
|
|
1193
1297
|
};
|
|
1194
1298
|
}
|
|
1299
|
+
_addCheck(check) {
|
|
1300
|
+
return new ZodDate({
|
|
1301
|
+
...this._def,
|
|
1302
|
+
checks: [...this._def.checks, check],
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
min(minDate, message) {
|
|
1306
|
+
return this._addCheck({
|
|
1307
|
+
kind: "min",
|
|
1308
|
+
value: minDate.getTime(),
|
|
1309
|
+
message: errorUtil.toString(message),
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
max(maxDate, message) {
|
|
1313
|
+
return this._addCheck({
|
|
1314
|
+
kind: "max",
|
|
1315
|
+
value: maxDate.getTime(),
|
|
1316
|
+
message: errorUtil.toString(message),
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
get minDate() {
|
|
1320
|
+
let min = null;
|
|
1321
|
+
for (const ch of this._def.checks) {
|
|
1322
|
+
if (ch.kind === "min") {
|
|
1323
|
+
if (min === null || ch.value > min)
|
|
1324
|
+
min = ch.value;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
return min != null ? new Date(min) : null;
|
|
1328
|
+
}
|
|
1329
|
+
get maxDate() {
|
|
1330
|
+
let max = null;
|
|
1331
|
+
for (const ch of this._def.checks) {
|
|
1332
|
+
if (ch.kind === "max") {
|
|
1333
|
+
if (max === null || ch.value < max)
|
|
1334
|
+
max = ch.value;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
return max != null ? new Date(max) : null;
|
|
1338
|
+
}
|
|
1195
1339
|
}
|
|
1196
1340
|
ZodDate.create = (params) => {
|
|
1197
1341
|
return new ZodDate({
|
|
1342
|
+
checks: [],
|
|
1198
1343
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
1199
1344
|
...processCreateParams(params),
|
|
1200
1345
|
});
|
|
@@ -1476,9 +1621,12 @@ class ZodObject extends ZodType {
|
|
|
1476
1621
|
const { status, ctx } = this._processInputParams(input);
|
|
1477
1622
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
1478
1623
|
const extraKeys = [];
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1624
|
+
if (!(this._def.catchall instanceof ZodNever &&
|
|
1625
|
+
this._def.unknownKeys === "strip")) {
|
|
1626
|
+
for (const key in ctx.data) {
|
|
1627
|
+
if (!shapeKeys.includes(key)) {
|
|
1628
|
+
extraKeys.push(key);
|
|
1629
|
+
}
|
|
1482
1630
|
}
|
|
1483
1631
|
}
|
|
1484
1632
|
const pairs = [];
|
|
@@ -1683,6 +1831,9 @@ class ZodObject extends ZodType {
|
|
|
1683
1831
|
shape: () => newShape,
|
|
1684
1832
|
});
|
|
1685
1833
|
}
|
|
1834
|
+
keyof() {
|
|
1835
|
+
return createZodEnum(util.objectKeys(this.shape));
|
|
1836
|
+
}
|
|
1686
1837
|
}
|
|
1687
1838
|
ZodObject.create = (shape, params) => {
|
|
1688
1839
|
return new ZodObject({
|
|
@@ -2043,6 +2194,9 @@ class ZodTuple extends ZodType {
|
|
|
2043
2194
|
}
|
|
2044
2195
|
}
|
|
2045
2196
|
ZodTuple.create = (schemas, params) => {
|
|
2197
|
+
if (!Array.isArray(schemas)) {
|
|
2198
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2199
|
+
}
|
|
2046
2200
|
return new ZodTuple({
|
|
2047
2201
|
items: schemas,
|
|
2048
2202
|
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
|
@@ -2270,8 +2424,8 @@ class ZodFunction extends ZodType {
|
|
|
2270
2424
|
errorMaps: [
|
|
2271
2425
|
ctx.common.contextualErrorMap,
|
|
2272
2426
|
ctx.schemaErrorMap,
|
|
2273
|
-
|
|
2274
|
-
|
|
2427
|
+
getErrorMap(),
|
|
2428
|
+
errorMap,
|
|
2275
2429
|
].filter((x) => !!x),
|
|
2276
2430
|
issueData: {
|
|
2277
2431
|
code: ZodIssueCode.invalid_arguments,
|
|
@@ -2286,8 +2440,8 @@ class ZodFunction extends ZodType {
|
|
|
2286
2440
|
errorMaps: [
|
|
2287
2441
|
ctx.common.contextualErrorMap,
|
|
2288
2442
|
ctx.schemaErrorMap,
|
|
2289
|
-
|
|
2290
|
-
|
|
2443
|
+
getErrorMap(),
|
|
2444
|
+
errorMap,
|
|
2291
2445
|
].filter((x) => !!x),
|
|
2292
2446
|
issueData: {
|
|
2293
2447
|
code: ZodIssueCode.invalid_return_type,
|
|
@@ -2357,17 +2511,17 @@ class ZodFunction extends ZodType {
|
|
|
2357
2511
|
const validatedFunc = this.parse(func);
|
|
2358
2512
|
return validatedFunc;
|
|
2359
2513
|
}
|
|
2514
|
+
static create(args, returns, params) {
|
|
2515
|
+
return new ZodFunction({
|
|
2516
|
+
args: (args
|
|
2517
|
+
? args
|
|
2518
|
+
: ZodTuple.create([]).rest(ZodUnknown.create())),
|
|
2519
|
+
returns: returns || ZodUnknown.create(),
|
|
2520
|
+
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
2521
|
+
...processCreateParams(params),
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2360
2524
|
}
|
|
2361
|
-
ZodFunction.create = (args, returns, params) => {
|
|
2362
|
-
return new ZodFunction({
|
|
2363
|
-
args: (args
|
|
2364
|
-
? args.rest(ZodUnknown.create())
|
|
2365
|
-
: ZodTuple.create([]).rest(ZodUnknown.create())),
|
|
2366
|
-
returns: returns || ZodUnknown.create(),
|
|
2367
|
-
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
2368
|
-
...processCreateParams(params),
|
|
2369
|
-
});
|
|
2370
|
-
};
|
|
2371
2525
|
class ZodLazy extends ZodType {
|
|
2372
2526
|
get schema() {
|
|
2373
2527
|
return this._def.getter();
|
|
@@ -2748,6 +2902,21 @@ ZodNaN.create = (params) => {
|
|
|
2748
2902
|
...processCreateParams(params),
|
|
2749
2903
|
});
|
|
2750
2904
|
};
|
|
2905
|
+
const BRAND = Symbol("zod_brand");
|
|
2906
|
+
class ZodBranded extends ZodType {
|
|
2907
|
+
_parse(input) {
|
|
2908
|
+
const { ctx } = this._processInputParams(input);
|
|
2909
|
+
const data = ctx.data;
|
|
2910
|
+
return this._def.type._parse({
|
|
2911
|
+
data,
|
|
2912
|
+
path: ctx.path,
|
|
2913
|
+
parent: ctx,
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
unwrap() {
|
|
2917
|
+
return this._def.type;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2751
2920
|
const custom = (check, params = {}, fatal) => {
|
|
2752
2921
|
if (check)
|
|
2753
2922
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
@@ -2795,7 +2964,14 @@ var ZodFirstPartyTypeKind;
|
|
|
2795
2964
|
ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
|
|
2796
2965
|
ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
|
|
2797
2966
|
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
|
|
2967
|
+
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
|
|
2798
2968
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
2969
|
+
// new approach that works for abstract classes
|
|
2970
|
+
// but required TS 4.4+
|
|
2971
|
+
// abstract class Class {
|
|
2972
|
+
// constructor(..._: any[]) {}
|
|
2973
|
+
// }
|
|
2974
|
+
// const instanceOfType = <T extends typeof Class>(
|
|
2799
2975
|
const instanceOfType = (cls, params = {
|
|
2800
2976
|
message: `Input not instance of ${cls.name}`,
|
|
2801
2977
|
}) => custom((data) => data instanceof cls, params, true);
|
|
@@ -2834,11 +3010,15 @@ const preprocessType = ZodEffects.createWithPreprocess;
|
|
|
2834
3010
|
const ostring = () => stringType().optional();
|
|
2835
3011
|
const onumber = () => numberType().optional();
|
|
2836
3012
|
const oboolean = () => booleanType().optional();
|
|
3013
|
+
const NEVER = INVALID;
|
|
2837
3014
|
|
|
2838
3015
|
var mod = /*#__PURE__*/Object.freeze({
|
|
2839
3016
|
__proto__: null,
|
|
2840
3017
|
getParsedType: getParsedType,
|
|
2841
3018
|
ZodParsedType: ZodParsedType,
|
|
3019
|
+
defaultErrorMap: errorMap,
|
|
3020
|
+
setErrorMap: setErrorMap,
|
|
3021
|
+
getErrorMap: getErrorMap,
|
|
2842
3022
|
makeIssue: makeIssue,
|
|
2843
3023
|
EMPTY_PATH: EMPTY_PATH,
|
|
2844
3024
|
addIssueToContext: addIssueToContext,
|
|
@@ -2884,6 +3064,8 @@ var mod = /*#__PURE__*/Object.freeze({
|
|
|
2884
3064
|
ZodNullable: ZodNullable,
|
|
2885
3065
|
ZodDefault: ZodDefault,
|
|
2886
3066
|
ZodNaN: ZodNaN,
|
|
3067
|
+
BRAND: BRAND,
|
|
3068
|
+
ZodBranded: ZodBranded,
|
|
2887
3069
|
custom: custom,
|
|
2888
3070
|
Schema: ZodType,
|
|
2889
3071
|
ZodSchema: ZodType,
|
|
@@ -2926,12 +3108,10 @@ var mod = /*#__PURE__*/Object.freeze({
|
|
|
2926
3108
|
union: unionType,
|
|
2927
3109
|
unknown: unknownType,
|
|
2928
3110
|
'void': voidType,
|
|
3111
|
+
NEVER: NEVER,
|
|
2929
3112
|
ZodIssueCode: ZodIssueCode,
|
|
2930
3113
|
quotelessJson: quotelessJson,
|
|
2931
|
-
ZodError: ZodError
|
|
2932
|
-
defaultErrorMap: defaultErrorMap,
|
|
2933
|
-
get overrideErrorMap () { return overrideErrorMap; },
|
|
2934
|
-
setErrorMap: setErrorMap
|
|
3114
|
+
ZodError: ZodError
|
|
2935
3115
|
});
|
|
2936
3116
|
|
|
2937
3117
|
var ContextValidator = mod.string().array();
|
|
@@ -2939,11 +3119,13 @@ mod.object({
|
|
|
2939
3119
|
type: mod.string().optional(),
|
|
2940
3120
|
narrative: mod.string().optional()
|
|
2941
3121
|
});
|
|
2942
|
-
var ImageValidator = mod.string().or(
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
3122
|
+
var ImageValidator = mod.string().or(
|
|
3123
|
+
mod.object({
|
|
3124
|
+
id: mod.string(),
|
|
3125
|
+
type: mod.string(),
|
|
3126
|
+
caption: mod.string().optional()
|
|
3127
|
+
})
|
|
3128
|
+
);
|
|
2947
3129
|
var GeoCoordinatesValidator = mod.object({
|
|
2948
3130
|
type: mod.string().min(1).or(mod.string().array().nonempty()),
|
|
2949
3131
|
latitude: mod.number(),
|
|
@@ -2985,29 +3167,31 @@ var IdentifierEntryValidator = mod.object({
|
|
|
2985
3167
|
identifier: mod.string(),
|
|
2986
3168
|
identifierType: IdentifierTypeValidator
|
|
2987
3169
|
});
|
|
2988
|
-
var ProfileValidator = mod.string().or(
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3170
|
+
var ProfileValidator = mod.string().or(
|
|
3171
|
+
mod.object({
|
|
3172
|
+
id: mod.string().optional(),
|
|
3173
|
+
type: mod.string().or(mod.string().array().nonempty().optional()),
|
|
3174
|
+
name: mod.string().optional(),
|
|
3175
|
+
url: mod.string().optional(),
|
|
3176
|
+
phone: mod.string().optional(),
|
|
3177
|
+
description: mod.string().optional(),
|
|
3178
|
+
endorsement: mod.any().array().optional(),
|
|
3179
|
+
image: ImageValidator.optional(),
|
|
3180
|
+
email: mod.string().email().optional(),
|
|
3181
|
+
address: AddressValidator.optional(),
|
|
3182
|
+
otherIdentifier: IdentifierEntryValidator.array().optional(),
|
|
3183
|
+
official: mod.string().optional(),
|
|
3184
|
+
parentOrg: mod.any().optional(),
|
|
3185
|
+
familyName: mod.string().optional(),
|
|
3186
|
+
givenName: mod.string().optional(),
|
|
3187
|
+
additionalName: mod.string().optional(),
|
|
3188
|
+
patronymicName: mod.string().optional(),
|
|
3189
|
+
honorificPrefix: mod.string().optional(),
|
|
3190
|
+
honorificSuffix: mod.string().optional(),
|
|
3191
|
+
familyNamePrefix: mod.string().optional(),
|
|
3192
|
+
dateOfBirth: mod.string().optional()
|
|
3193
|
+
}).catchall(mod.any())
|
|
3194
|
+
);
|
|
3011
3195
|
var CredentialSubjectValidator = mod.object({ id: mod.string().optional() }).catchall(mod.any());
|
|
3012
3196
|
var CredentialStatusValidator = mod.object({ type: mod.string(), id: mod.string() });
|
|
3013
3197
|
var CredentialSchemaValidator = mod.object({ id: mod.string(), type: mod.string() });
|
|
@@ -3319,4 +3503,4 @@ const VCVerificationPill = ({
|
|
|
3319
3503
|
|
|
3320
3504
|
exports.VCVerificationPill = VCVerificationPill;
|
|
3321
3505
|
exports.ValidationStateIndicator = ValidationStateIndicator;
|
|
3322
|
-
//# sourceMappingURL=VCVerificationPill-
|
|
3506
|
+
//# sourceMappingURL=VCVerificationPill-e1b817ac.js.map
|