@nu-art/ts-common 0.202.11 → 0.202.12

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/ts-common",
3
- "version": "0.202.11",
3
+ "version": "0.202.12",
4
4
  "description": "js and ts infra",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -22,6 +22,7 @@ export declare const tsValidateRegexp: (regexp: RegExp, mandatory?: boolean) =>
22
22
  export declare const tsValidateTimestamp: (interval?: number, mandatory?: boolean) => Validator<number>;
23
23
  export declare const tsValidateAudit: (range?: RangeTimestamp) => (audit?: AuditBy) => any;
24
24
  export declare const tsValidateNonMandatoryObject: <T>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) => any)[];
25
+ export declare const tsValidateOptionalObject: <T>(validator: ValidatorTypeResolver<T>) => ((input?: T | undefined) => any)[];
25
26
  export declare const tsValidator_valueByKey: <T extends unknown>(validatorObject: {
26
27
  [k: string]: Validator<any> | import("./validator-core").TypeValidator<any>;
27
28
  }) => ValidatorTypeResolver<T>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tsValidator_ArrayOfObjectsByKey = exports.tsValidator_valueByKey = exports.tsValidateNonMandatoryObject = 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_ArrayOfObjectsByKey = exports.tsValidator_valueByKey = exports.tsValidateOptionalObject = exports.tsValidateNonMandatoryObject = 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");
@@ -132,7 +132,7 @@ const tsValidateValue = (values, mandatory = true) => {
132
132
  (input) => {
133
133
  if (values.includes(input))
134
134
  return;
135
- return `Input is not valid:\n input: ${input}\n options: ${(0, tools_1.__stringify)(values)}\n`;
135
+ return `Input is not valid:\n input: ${input && (0, tools_1.__stringify)(input) || input}\n options: ${(0, tools_1.__stringify)(values)}\n`;
136
136
  }];
137
137
  };
138
138
  exports.tsValidateValue = tsValidateValue;
@@ -193,6 +193,7 @@ const tsValidateNonMandatoryObject = (validator) => {
193
193
  (input) => (0, validator_core_1.tsValidateResult)(input, validator)];
194
194
  };
195
195
  exports.tsValidateNonMandatoryObject = tsValidateNonMandatoryObject;
196
+ exports.tsValidateOptionalObject = exports.tsValidateNonMandatoryObject;
196
197
  const tsValidator_valueByKey = (validatorObject) => {
197
198
  return (0, exports.tsValidateCustom)((value, parentObject) => {
198
199
  return (0, validator_core_1.tsValidateResult)(value, validatorObject[parentObject.type]);
@@ -79,7 +79,7 @@ const tsValidateResult = (instance, _validator, key, parentInstance) => {
79
79
  }
80
80
  if (typeof validator === 'object') {
81
81
  if (!instance && validator)
82
- return `Unexpected object:\n The key '${String(key)}' wasn't defined in the instance.`;
82
+ return `Missing Property:\n The key '${String(key)}' wasn't defined in the instance.`;
83
83
  if (typeof instance !== 'object')
84
84
  return `Unexpected instance '${instance}'.\nExpected to receive an object, but received something else.`;
85
85
  const __validator = validator;