@nu-art/ts-common 0.203.76 → 0.203.78
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/package.json
CHANGED
package/utils/types.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export type Draftable = {
|
|
|
120
120
|
/**
|
|
121
121
|
* call function 'resolveContent(resolvableContentObject)' to receive the content which is T.
|
|
122
122
|
*/
|
|
123
|
-
export type ResolvableContent<T, K extends any[] =
|
|
123
|
+
export type ResolvableContent<T, K extends any[] = any[]> = T | ((...param: K) => T);
|
|
124
124
|
export type Auditable = {
|
|
125
125
|
_audit?: AuditBy;
|
|
126
126
|
};
|
|
@@ -31,4 +31,5 @@ export declare const tsValidator_valueByKey: <T>(validatorObject: {
|
|
|
31
31
|
export declare const tsValidator_ArrayOfObjectsByKey: <T extends Object>(key: keyof T, validatorMap: {
|
|
32
32
|
[k: string]: ValidatorTypeResolver<T>;
|
|
33
33
|
}) => Validator<T[]>;
|
|
34
|
+
export declare const tsValidator_stringOrNumber: (mandatory?: boolean) => ValidatorTypeResolver<string | number>;
|
|
34
35
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tsValidator_ArrayOfObjectsByKey = exports.tsValidator_valueByKey = exports.tsValidateOptionalObject = exports.tsValidateNonMandatoryObject = exports.tsValidateTimeRange = exports.tsValidateAudit = exports.tsValidateTimestamp = exports.tsValidateRegexp = exports.tsValidateRange = exports.tsValidateIsInRange = exports.tsValidateValue = exports.tsValidateBoolean = exports.tsValidateEnum = exports.tsValidateNumber = exports.tsValidateStringMinLength = exports.tsValidateString = exports.tsValidateArray = exports.tsValidateUnionV3 = exports.tsValidateCustom = exports.tsValidateUnion = exports.tsValidateDynamicObject = void 0;
|
|
3
|
+
exports.tsValidator_stringOrNumber = exports.tsValidator_ArrayOfObjectsByKey = exports.tsValidator_valueByKey = exports.tsValidateOptionalObject = exports.tsValidateNonMandatoryObject = exports.tsValidateTimeRange = exports.tsValidateAudit = exports.tsValidateTimestamp = exports.tsValidateRegexp = exports.tsValidateRange = exports.tsValidateIsInRange = exports.tsValidateValue = exports.tsValidateBoolean = exports.tsValidateEnum = exports.tsValidateNumber = exports.tsValidateStringMinLength = exports.tsValidateString = exports.tsValidateArray = exports.tsValidateUnionV3 = exports.tsValidateCustom = exports.tsValidateUnion = exports.tsValidateDynamicObject = void 0;
|
|
4
4
|
const tools_1 = require("../utils/tools");
|
|
5
5
|
const validator_core_1 = require("./validator-core");
|
|
6
6
|
const date_time_tools_1 = require("../utils/date-time-tools");
|
|
@@ -232,3 +232,15 @@ const tsValidator_ArrayOfObjectsByKey = (key, validatorMap) => {
|
|
|
232
232
|
}));
|
|
233
233
|
};
|
|
234
234
|
exports.tsValidator_ArrayOfObjectsByKey = tsValidator_ArrayOfObjectsByKey;
|
|
235
|
+
const tsValidator_stringOrNumber = (mandatory = true) => {
|
|
236
|
+
return (0, exports.tsValidateCustom)((input) => {
|
|
237
|
+
switch (typeof input) {
|
|
238
|
+
case 'string':
|
|
239
|
+
return (0, validator_core_1.tsValidateResult)(input, (0, exports.tsValidateString)());
|
|
240
|
+
case 'number':
|
|
241
|
+
return (0, validator_core_1.tsValidateResult)(input, (0, exports.tsValidateNumber)());
|
|
242
|
+
}
|
|
243
|
+
return 'Input is not string or number.';
|
|
244
|
+
}, mandatory);
|
|
245
|
+
};
|
|
246
|
+
exports.tsValidator_stringOrNumber = tsValidator_stringOrNumber;
|