valgen 5.13.3 → 5.13.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # v5.13.4
2
+ [2025-03-26]
3
+
4
+ ### Fixes
5
+
6
+ * fix: isNotEmpty do not work for number and boolean types ([`e5175d8`](https://github.com/panates/valgen/commit/e5175d82f532a0a8370754fa6739a13221401788))
7
+
1
8
  # v5.13.3
2
9
  [2025-03-17]
3
10
 
@@ -63,38 +63,46 @@ function isNotEmpty(options) {
63
63
  context.fail(_this, `Value must not be empty`, input);
64
64
  return input;
65
65
  }
66
- else if (Array.isArray(input)) {
67
- if (!input.length)
68
- context.fail(_this, `Array must not be empty`, input);
69
- return input;
70
- }
71
- else if (input instanceof Set) {
72
- if (!input.size)
73
- context.fail(_this, `Set must not be empty`, input);
74
- return input;
75
- }
76
- else if (input instanceof Map) {
77
- if (!input.size)
78
- context.fail(_this, `Map must not be empty`, input);
79
- return input;
80
- }
81
- else if (Buffer.isBuffer(input)) {
82
- if (!input.length)
83
- context.fail(_this, `Buffer must not be empty`, input);
84
- return input;
85
- }
86
- else if (input instanceof ArrayBuffer) {
87
- if (!input.byteLength)
88
- context.fail(_this, `ArrayBuffer must not be empty`, input);
66
+ else if (typeof input === 'number') {
67
+ if (Number.isNaN(input))
68
+ context.fail(_this, `Value must not be NaN`, input);
89
69
  return input;
90
70
  }
91
71
  else if (typeof input === 'object') {
92
- if (input instanceof Date)
72
+ if (Array.isArray(input)) {
73
+ if (!input.length)
74
+ context.fail(_this, `Array must not be empty`, input);
93
75
  return input;
94
- if (!Object.keys(input).length)
95
- context.fail(_this, `Object must not be empty`, input);
96
- return input;
76
+ }
77
+ else if (input instanceof Set) {
78
+ if (!input.size)
79
+ context.fail(_this, `Set must not be empty`, input);
80
+ return input;
81
+ }
82
+ else if (input instanceof Map) {
83
+ if (!input.size)
84
+ context.fail(_this, `Map must not be empty`, input);
85
+ return input;
86
+ }
87
+ else if (Buffer.isBuffer(input)) {
88
+ if (!input.length)
89
+ context.fail(_this, `Buffer must not be empty`, input);
90
+ return input;
91
+ }
92
+ else if (input instanceof ArrayBuffer) {
93
+ if (!input.byteLength)
94
+ context.fail(_this, `ArrayBuffer must not be empty`, input);
95
+ return input;
96
+ }
97
+ else {
98
+ if (input instanceof Date)
99
+ return input;
100
+ if (!Object.keys(input).length)
101
+ context.fail(_this, `Object must not be empty`, input);
102
+ return input;
103
+ }
97
104
  }
105
+ return input;
98
106
  }
99
107
  context.fail(_this, `Value must not be empty`, input);
100
108
  return input;
@@ -59,38 +59,46 @@ export function isNotEmpty(options) {
59
59
  context.fail(_this, `Value must not be empty`, input);
60
60
  return input;
61
61
  }
62
- else if (Array.isArray(input)) {
63
- if (!input.length)
64
- context.fail(_this, `Array must not be empty`, input);
65
- return input;
66
- }
67
- else if (input instanceof Set) {
68
- if (!input.size)
69
- context.fail(_this, `Set must not be empty`, input);
70
- return input;
71
- }
72
- else if (input instanceof Map) {
73
- if (!input.size)
74
- context.fail(_this, `Map must not be empty`, input);
75
- return input;
76
- }
77
- else if (Buffer.isBuffer(input)) {
78
- if (!input.length)
79
- context.fail(_this, `Buffer must not be empty`, input);
80
- return input;
81
- }
82
- else if (input instanceof ArrayBuffer) {
83
- if (!input.byteLength)
84
- context.fail(_this, `ArrayBuffer must not be empty`, input);
62
+ else if (typeof input === 'number') {
63
+ if (Number.isNaN(input))
64
+ context.fail(_this, `Value must not be NaN`, input);
85
65
  return input;
86
66
  }
87
67
  else if (typeof input === 'object') {
88
- if (input instanceof Date)
68
+ if (Array.isArray(input)) {
69
+ if (!input.length)
70
+ context.fail(_this, `Array must not be empty`, input);
89
71
  return input;
90
- if (!Object.keys(input).length)
91
- context.fail(_this, `Object must not be empty`, input);
92
- return input;
72
+ }
73
+ else if (input instanceof Set) {
74
+ if (!input.size)
75
+ context.fail(_this, `Set must not be empty`, input);
76
+ return input;
77
+ }
78
+ else if (input instanceof Map) {
79
+ if (!input.size)
80
+ context.fail(_this, `Map must not be empty`, input);
81
+ return input;
82
+ }
83
+ else if (Buffer.isBuffer(input)) {
84
+ if (!input.length)
85
+ context.fail(_this, `Buffer must not be empty`, input);
86
+ return input;
87
+ }
88
+ else if (input instanceof ArrayBuffer) {
89
+ if (!input.byteLength)
90
+ context.fail(_this, `ArrayBuffer must not be empty`, input);
91
+ return input;
92
+ }
93
+ else {
94
+ if (input instanceof Date)
95
+ return input;
96
+ if (!Object.keys(input).length)
97
+ context.fail(_this, `Object must not be empty`, input);
98
+ return input;
99
+ }
93
100
  }
101
+ return input;
94
102
  }
95
103
  context.fail(_this, `Value must not be empty`, input);
96
104
  return input;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valgen",
3
3
  "description": "Fast runtime type validator, converter and io (encoding/decoding) library",
4
- "version": "5.13.3",
4
+ "version": "5.13.4",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
package/types/index.d.cts CHANGED
@@ -8,8 +8,8 @@ declare const isBigint: import("./core/validator.js").Validator<bigint, unknown,
8
8
  declare const isBoolean: import("./core/validator.js").Validator<boolean | undefined, unknown, import("./core/types.js").ExecutionOptions>;
9
9
  declare const isDate: import("./core/validator.js").Validator<Date, string | number | Date, import("./core/types.js").ExecutionOptions>;
10
10
  declare const isDateString: import("./core/validator.js").Validator<string, string | number | Date, import("./core/types.js").ExecutionOptions>;
11
- declare const isEmpty: import("./core/validator.js").Validator<string | object | any[] | Set<any> | Map<any, any>, string | object | any[] | Set<any> | Map<any, any>, import("./core/types.js").ExecutionOptions>;
12
- declare const isNotEmpty: import("./core/validator.js").Validator<string | object | any[] | Set<any> | Map<any, any>, string | object | any[] | Set<any> | Map<any, any>, import("./core/types.js").ExecutionOptions>;
11
+ declare const isEmpty: import("./core/validator.js").Validator<any, any, import("./core/types.js").ExecutionOptions>;
12
+ declare const isNotEmpty: import("./core/validator.js").Validator<any, any, import("./core/types.js").ExecutionOptions>;
13
13
  declare const isInteger: import("./core/validator.js").Validator<number, unknown, import("./core/types.js").ExecutionOptions>;
14
14
  declare const isNull: import("./core/validator.js").Validator<null, unknown, import("./core/types.js").ExecutionOptions>;
15
15
  declare const isNotNull: import("./core/validator.js").Validator<unknown, unknown, import("./core/types.js").ExecutionOptions>;
package/types/index.d.ts CHANGED
@@ -8,8 +8,8 @@ declare const isBigint: import("./core/validator.js").Validator<bigint, unknown,
8
8
  declare const isBoolean: import("./core/validator.js").Validator<boolean | undefined, unknown, import("./core/types.js").ExecutionOptions>;
9
9
  declare const isDate: import("./core/validator.js").Validator<Date, string | number | Date, import("./core/types.js").ExecutionOptions>;
10
10
  declare const isDateString: import("./core/validator.js").Validator<string, string | number | Date, import("./core/types.js").ExecutionOptions>;
11
- declare const isEmpty: import("./core/validator.js").Validator<string | object | any[] | Set<any> | Map<any, any>, string | object | any[] | Set<any> | Map<any, any>, import("./core/types.js").ExecutionOptions>;
12
- declare const isNotEmpty: import("./core/validator.js").Validator<string | object | any[] | Set<any> | Map<any, any>, string | object | any[] | Set<any> | Map<any, any>, import("./core/types.js").ExecutionOptions>;
11
+ declare const isEmpty: import("./core/validator.js").Validator<any, any, import("./core/types.js").ExecutionOptions>;
12
+ declare const isNotEmpty: import("./core/validator.js").Validator<any, any, import("./core/types.js").ExecutionOptions>;
13
13
  declare const isInteger: import("./core/validator.js").Validator<number, unknown, import("./core/types.js").ExecutionOptions>;
14
14
  declare const isNull: import("./core/validator.js").Validator<null, unknown, import("./core/types.js").ExecutionOptions>;
15
15
  declare const isNotNull: import("./core/validator.js").Validator<unknown, unknown, import("./core/types.js").ExecutionOptions>;
@@ -1,13 +1,11 @@
1
1
  import { type ValidationOptions } from '../../core/index.js';
2
- type IsEmptyInput = string | any[] | object | Set<any> | Map<any, any>;
3
2
  /**
4
3
  * Checks if value is an empty. Value should be string, array, set, map or object
5
4
  * @validator isEmpty
6
5
  */
7
- export declare function isEmpty(options?: ValidationOptions): import("../../core/validator.js").Validator<IsEmptyInput, IsEmptyInput, import("../../core/types.js").ExecutionOptions>;
6
+ export declare function isEmpty(options?: ValidationOptions): import("../../core/validator.js").Validator<any, any, import("../../core/types.js").ExecutionOptions>;
8
7
  /**
9
8
  * Checks if value is a not empty. Value should be string, array, set, map or object
10
9
  * @validator isNotEmpty
11
10
  */
12
- export declare function isNotEmpty(options?: ValidationOptions): import("../../core/validator.js").Validator<IsEmptyInput, IsEmptyInput, import("../../core/types.js").ExecutionOptions>;
13
- export {};
11
+ export declare function isNotEmpty(options?: ValidationOptions): import("../../core/validator.js").Validator<any, any, import("../../core/types.js").ExecutionOptions>;