@alextheman/utility 4.8.0 → 4.9.0
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/index.cjs +52 -20
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +52 -21
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -851,25 +851,8 @@ function parseBoolean(inputString) {
|
|
|
851
851
|
var parseBoolean_default = parseBoolean;
|
|
852
852
|
|
|
853
853
|
//#endregion
|
|
854
|
-
//#region src/functions/parsers/
|
|
855
|
-
|
|
856
|
-
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
857
|
-
*
|
|
858
|
-
* @category Parsers
|
|
859
|
-
*
|
|
860
|
-
* @template SchemaType - The Zod schema type.
|
|
861
|
-
* @template ErrorType - The type of error to throw on invalid data.
|
|
862
|
-
*
|
|
863
|
-
* @param schema - The Zod schema to use in parsing.
|
|
864
|
-
* @param data - The data to parse.
|
|
865
|
-
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
866
|
-
*
|
|
867
|
-
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
868
|
-
*
|
|
869
|
-
* @returns The parsed data from the Zod schema.
|
|
870
|
-
*/
|
|
871
|
-
function parseZodSchema(schema, data, onError) {
|
|
872
|
-
const parsedResult = schema.safeParse(data);
|
|
854
|
+
//#region src/functions/parsers/zod/_parseZodSchema.ts
|
|
855
|
+
function _parseZodSchema(parsedResult, data, onError) {
|
|
873
856
|
if (!parsedResult.success) {
|
|
874
857
|
if (onError) {
|
|
875
858
|
if (onError instanceof Error) throw onError;
|
|
@@ -887,10 +870,35 @@ function parseZodSchema(schema, data, onError) {
|
|
|
887
870
|
return secondCount - firstCount;
|
|
888
871
|
}).map(([code, count], _, allErrorCodes$1) => {
|
|
889
872
|
return allErrorCodes$1.length === 1 && count === 1 ? code : `${code}×${count}`;
|
|
890
|
-
}).join(","), `\n\n${zod.
|
|
873
|
+
}).join(","), `\n\n${zod.default.prettifyError(parsedResult.error)}\n`);
|
|
891
874
|
}
|
|
892
875
|
return parsedResult.data;
|
|
893
876
|
}
|
|
877
|
+
var _parseZodSchema_default = _parseZodSchema;
|
|
878
|
+
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/functions/parsers/zod/parseZodSchema.ts
|
|
881
|
+
/**
|
|
882
|
+
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
883
|
+
*
|
|
884
|
+
* NOTE: Use `parseZodSchemaAsync` if your schema includes an asynchronous function.
|
|
885
|
+
*
|
|
886
|
+
* @category Parsers
|
|
887
|
+
*
|
|
888
|
+
* @template SchemaType - The Zod schema type.
|
|
889
|
+
* @template ErrorType - The type of error to throw on invalid data.
|
|
890
|
+
*
|
|
891
|
+
* @param schema - The Zod schema to use in parsing.
|
|
892
|
+
* @param data - The data to parse.
|
|
893
|
+
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
894
|
+
*
|
|
895
|
+
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
896
|
+
*
|
|
897
|
+
* @returns The parsed data from the Zod schema.
|
|
898
|
+
*/
|
|
899
|
+
function parseZodSchema(schema, data, onError) {
|
|
900
|
+
return _parseZodSchema_default(schema.safeParse(data), data, onError);
|
|
901
|
+
}
|
|
894
902
|
var parseZodSchema_default = parseZodSchema;
|
|
895
903
|
|
|
896
904
|
//#endregion
|
|
@@ -973,6 +981,29 @@ function parseVersionType(data) {
|
|
|
973
981
|
}
|
|
974
982
|
var parseVersionType_default = parseVersionType;
|
|
975
983
|
|
|
984
|
+
//#endregion
|
|
985
|
+
//#region src/functions/parsers/zod/parseZodSchemaAsync.ts
|
|
986
|
+
/**
|
|
987
|
+
* An alternative function to zodSchema.parseAsync() that can be used to strictly parse asynchronous Zod schemas.
|
|
988
|
+
*
|
|
989
|
+
* @category Parsers
|
|
990
|
+
*
|
|
991
|
+
* @template SchemaType - The Zod schema type.
|
|
992
|
+
* @template ErrorType - The type of error to throw on invalid data.
|
|
993
|
+
*
|
|
994
|
+
* @param schema - The Zod schema to use in parsing.
|
|
995
|
+
* @param data - The data to parse.
|
|
996
|
+
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
997
|
+
*
|
|
998
|
+
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
999
|
+
*
|
|
1000
|
+
* @returns The parsed data from the Zod schema.
|
|
1001
|
+
*/
|
|
1002
|
+
async function parseZodSchemaAsync(schema, data, onError) {
|
|
1003
|
+
return _parseZodSchema_default(await schema.safeParseAsync(data), data, onError);
|
|
1004
|
+
}
|
|
1005
|
+
var parseZodSchemaAsync_default = parseZodSchemaAsync;
|
|
1006
|
+
|
|
976
1007
|
//#endregion
|
|
977
1008
|
//#region src/functions/recursive/deepCopy.ts
|
|
978
1009
|
function callDeepCopy(input) {
|
|
@@ -1527,6 +1558,7 @@ exports.parseIntStrict = parseIntStrict_default;
|
|
|
1527
1558
|
exports.parseVersion = parseVersion_default;
|
|
1528
1559
|
exports.parseVersionType = parseVersionType_default;
|
|
1529
1560
|
exports.parseZodSchema = parseZodSchema_default;
|
|
1561
|
+
exports.parseZodSchemaAsync = parseZodSchemaAsync_default;
|
|
1530
1562
|
exports.randomiseArray = randomiseArray_default;
|
|
1531
1563
|
exports.range = range_default;
|
|
1532
1564
|
exports.removeDuplicates = removeDuplicates_default;
|
package/dist/index.d.cts
CHANGED
|
@@ -678,10 +678,12 @@ type VersionType = CreateEnumType<typeof VersionType>;
|
|
|
678
678
|
*/
|
|
679
679
|
declare function parseVersionType(data: unknown): VersionType;
|
|
680
680
|
//#endregion
|
|
681
|
-
//#region src/functions/parsers/parseZodSchema.d.ts
|
|
681
|
+
//#region src/functions/parsers/zod/parseZodSchema.d.ts
|
|
682
682
|
/**
|
|
683
683
|
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
684
684
|
*
|
|
685
|
+
* NOTE: Use `parseZodSchemaAsync` if your schema includes an asynchronous function.
|
|
686
|
+
*
|
|
685
687
|
* @category Parsers
|
|
686
688
|
*
|
|
687
689
|
* @template SchemaType - The Zod schema type.
|
|
@@ -697,6 +699,25 @@ declare function parseVersionType(data: unknown): VersionType;
|
|
|
697
699
|
*/
|
|
698
700
|
declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): z.infer<SchemaType>;
|
|
699
701
|
//#endregion
|
|
702
|
+
//#region src/functions/parsers/zod/parseZodSchemaAsync.d.ts
|
|
703
|
+
/**
|
|
704
|
+
* An alternative function to zodSchema.parseAsync() that can be used to strictly parse asynchronous Zod schemas.
|
|
705
|
+
*
|
|
706
|
+
* @category Parsers
|
|
707
|
+
*
|
|
708
|
+
* @template SchemaType - The Zod schema type.
|
|
709
|
+
* @template ErrorType - The type of error to throw on invalid data.
|
|
710
|
+
*
|
|
711
|
+
* @param schema - The Zod schema to use in parsing.
|
|
712
|
+
* @param data - The data to parse.
|
|
713
|
+
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
714
|
+
*
|
|
715
|
+
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
716
|
+
*
|
|
717
|
+
* @returns The parsed data from the Zod schema.
|
|
718
|
+
*/
|
|
719
|
+
declare function parseZodSchemaAsync<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): Promise<z.infer<SchemaType>>;
|
|
720
|
+
//#endregion
|
|
700
721
|
//#region src/functions/recursive/deepCopy.d.ts
|
|
701
722
|
/**
|
|
702
723
|
* Deeply copies an object or array such that all child objects/arrays are also copied.
|
|
@@ -1051,4 +1072,4 @@ interface ParseVersionOptions {
|
|
|
1051
1072
|
*/
|
|
1052
1073
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
1053
1074
|
//#endregion
|
|
1054
|
-
export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, stringListToArray, stringifyDotenv, truncate, wait };
|
|
1075
|
+
export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, stringListToArray, stringifyDotenv, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -678,10 +678,12 @@ type VersionType = CreateEnumType<typeof VersionType>;
|
|
|
678
678
|
*/
|
|
679
679
|
declare function parseVersionType(data: unknown): VersionType;
|
|
680
680
|
//#endregion
|
|
681
|
-
//#region src/functions/parsers/parseZodSchema.d.ts
|
|
681
|
+
//#region src/functions/parsers/zod/parseZodSchema.d.ts
|
|
682
682
|
/**
|
|
683
683
|
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
684
684
|
*
|
|
685
|
+
* NOTE: Use `parseZodSchemaAsync` if your schema includes an asynchronous function.
|
|
686
|
+
*
|
|
685
687
|
* @category Parsers
|
|
686
688
|
*
|
|
687
689
|
* @template SchemaType - The Zod schema type.
|
|
@@ -697,6 +699,25 @@ declare function parseVersionType(data: unknown): VersionType;
|
|
|
697
699
|
*/
|
|
698
700
|
declare function parseZodSchema<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): z$1.infer<SchemaType>;
|
|
699
701
|
//#endregion
|
|
702
|
+
//#region src/functions/parsers/zod/parseZodSchemaAsync.d.ts
|
|
703
|
+
/**
|
|
704
|
+
* An alternative function to zodSchema.parseAsync() that can be used to strictly parse asynchronous Zod schemas.
|
|
705
|
+
*
|
|
706
|
+
* @category Parsers
|
|
707
|
+
*
|
|
708
|
+
* @template SchemaType - The Zod schema type.
|
|
709
|
+
* @template ErrorType - The type of error to throw on invalid data.
|
|
710
|
+
*
|
|
711
|
+
* @param schema - The Zod schema to use in parsing.
|
|
712
|
+
* @param data - The data to parse.
|
|
713
|
+
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
714
|
+
*
|
|
715
|
+
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
716
|
+
*
|
|
717
|
+
* @returns The parsed data from the Zod schema.
|
|
718
|
+
*/
|
|
719
|
+
declare function parseZodSchemaAsync<SchemaType extends ZodType, ErrorType extends Error>(schema: SchemaType, data: unknown, onError?: ErrorType | ((zodError: ZodError) => ErrorType | void)): Promise<z$1.infer<SchemaType>>;
|
|
720
|
+
//#endregion
|
|
700
721
|
//#region src/functions/recursive/deepCopy.d.ts
|
|
701
722
|
/**
|
|
702
723
|
* Deeply copies an object or array such that all child objects/arrays are also copied.
|
|
@@ -1051,4 +1072,4 @@ interface ParseVersionOptions {
|
|
|
1051
1072
|
*/
|
|
1052
1073
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
1053
1074
|
//#endregion
|
|
1054
|
-
export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, stringListToArray, stringifyDotenv, truncate, wait };
|
|
1075
|
+
export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, stringListToArray, stringifyDotenv, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -821,25 +821,8 @@ function parseBoolean(inputString) {
|
|
|
821
821
|
var parseBoolean_default = parseBoolean;
|
|
822
822
|
|
|
823
823
|
//#endregion
|
|
824
|
-
//#region src/functions/parsers/
|
|
825
|
-
|
|
826
|
-
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
827
|
-
*
|
|
828
|
-
* @category Parsers
|
|
829
|
-
*
|
|
830
|
-
* @template SchemaType - The Zod schema type.
|
|
831
|
-
* @template ErrorType - The type of error to throw on invalid data.
|
|
832
|
-
*
|
|
833
|
-
* @param schema - The Zod schema to use in parsing.
|
|
834
|
-
* @param data - The data to parse.
|
|
835
|
-
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
836
|
-
*
|
|
837
|
-
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
838
|
-
*
|
|
839
|
-
* @returns The parsed data from the Zod schema.
|
|
840
|
-
*/
|
|
841
|
-
function parseZodSchema(schema, data, onError) {
|
|
842
|
-
const parsedResult = schema.safeParse(data);
|
|
824
|
+
//#region src/functions/parsers/zod/_parseZodSchema.ts
|
|
825
|
+
function _parseZodSchema(parsedResult, data, onError) {
|
|
843
826
|
if (!parsedResult.success) {
|
|
844
827
|
if (onError) {
|
|
845
828
|
if (onError instanceof Error) throw onError;
|
|
@@ -857,10 +840,35 @@ function parseZodSchema(schema, data, onError) {
|
|
|
857
840
|
return secondCount - firstCount;
|
|
858
841
|
}).map(([code, count], _, allErrorCodes$1) => {
|
|
859
842
|
return allErrorCodes$1.length === 1 && count === 1 ? code : `${code}×${count}`;
|
|
860
|
-
}).join(","), `\n\n${z
|
|
843
|
+
}).join(","), `\n\n${z.prettifyError(parsedResult.error)}\n`);
|
|
861
844
|
}
|
|
862
845
|
return parsedResult.data;
|
|
863
846
|
}
|
|
847
|
+
var _parseZodSchema_default = _parseZodSchema;
|
|
848
|
+
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region src/functions/parsers/zod/parseZodSchema.ts
|
|
851
|
+
/**
|
|
852
|
+
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
853
|
+
*
|
|
854
|
+
* NOTE: Use `parseZodSchemaAsync` if your schema includes an asynchronous function.
|
|
855
|
+
*
|
|
856
|
+
* @category Parsers
|
|
857
|
+
*
|
|
858
|
+
* @template SchemaType - The Zod schema type.
|
|
859
|
+
* @template ErrorType - The type of error to throw on invalid data.
|
|
860
|
+
*
|
|
861
|
+
* @param schema - The Zod schema to use in parsing.
|
|
862
|
+
* @param data - The data to parse.
|
|
863
|
+
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
864
|
+
*
|
|
865
|
+
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
866
|
+
*
|
|
867
|
+
* @returns The parsed data from the Zod schema.
|
|
868
|
+
*/
|
|
869
|
+
function parseZodSchema(schema, data, onError) {
|
|
870
|
+
return _parseZodSchema_default(schema.safeParse(data), data, onError);
|
|
871
|
+
}
|
|
864
872
|
var parseZodSchema_default = parseZodSchema;
|
|
865
873
|
|
|
866
874
|
//#endregion
|
|
@@ -943,6 +951,29 @@ function parseVersionType(data) {
|
|
|
943
951
|
}
|
|
944
952
|
var parseVersionType_default = parseVersionType;
|
|
945
953
|
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/functions/parsers/zod/parseZodSchemaAsync.ts
|
|
956
|
+
/**
|
|
957
|
+
* An alternative function to zodSchema.parseAsync() that can be used to strictly parse asynchronous Zod schemas.
|
|
958
|
+
*
|
|
959
|
+
* @category Parsers
|
|
960
|
+
*
|
|
961
|
+
* @template SchemaType - The Zod schema type.
|
|
962
|
+
* @template ErrorType - The type of error to throw on invalid data.
|
|
963
|
+
*
|
|
964
|
+
* @param schema - The Zod schema to use in parsing.
|
|
965
|
+
* @param data - The data to parse.
|
|
966
|
+
* @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
|
|
967
|
+
*
|
|
968
|
+
* @throws {DataError} If the given data cannot be parsed according to the schema.
|
|
969
|
+
*
|
|
970
|
+
* @returns The parsed data from the Zod schema.
|
|
971
|
+
*/
|
|
972
|
+
async function parseZodSchemaAsync(schema, data, onError) {
|
|
973
|
+
return _parseZodSchema_default(await schema.safeParseAsync(data), data, onError);
|
|
974
|
+
}
|
|
975
|
+
var parseZodSchemaAsync_default = parseZodSchemaAsync;
|
|
976
|
+
|
|
946
977
|
//#endregion
|
|
947
978
|
//#region src/functions/recursive/deepCopy.ts
|
|
948
979
|
function callDeepCopy(input) {
|
|
@@ -1451,4 +1482,4 @@ function incrementVersion(version, incrementType, options) {
|
|
|
1451
1482
|
var incrementVersion_default = incrementVersion;
|
|
1452
1483
|
|
|
1453
1484
|
//#endregion
|
|
1454
|
-
export { APIError_default as APIError, DataError_default as DataError, Env, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, VersionNumber_default as VersionNumber, VersionType, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, deepCopy_default as deepCopy, deepFreeze_default as deepFreeze, determineVersionType_default as determineVersionType, encryptWithKey_default as encryptWithKey, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getInterpolations_default as getInterpolations, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, incrementVersion_default as incrementVersion, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normaliseIndents_default as normaliseIndents, normalizeImportPath_default as normalizeImportPath, normalizeIndents, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, parseEnv_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, stringListToArray_default as stringListToArray, stringifyDotenv_default as stringifyDotenv, truncate_default as truncate, wait_default as wait };
|
|
1485
|
+
export { APIError_default as APIError, DataError_default as DataError, Env, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, VersionNumber_default as VersionNumber, VersionType, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, deepCopy_default as deepCopy, deepFreeze_default as deepFreeze, determineVersionType_default as determineVersionType, encryptWithKey_default as encryptWithKey, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getInterpolations_default as getInterpolations, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, incrementVersion_default as incrementVersion, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normaliseIndents_default as normaliseIndents, normalizeImportPath_default as normalizeImportPath, normalizeIndents, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, parseEnv_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, parseZodSchemaAsync_default as parseZodSchemaAsync, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, stringListToArray_default as stringListToArray, stringifyDotenv_default as stringifyDotenv, truncate_default as truncate, wait_default as wait };
|