@kalutskii/foundation 0.6.3 → 0.6.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/dist/index.d.ts CHANGED
@@ -223,7 +223,7 @@ type Simplify<T> = {
223
223
  * Transforms a string to a number (when passing query parameters).
224
224
  * Example usage: `asQueryNumber(z.number())('123') = 123`
225
225
  */
226
- declare const asQueryNumber: <T extends z.ZodNumber | z.ZodInt>(schema: T) => z.ZodPreprocess<T>;
226
+ declare const asQueryNumber: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>;
227
227
  /**
228
228
  * Transforms various string representations of boolean values into actual booleans.
229
229
  * See POSITIVE_VALUES and NEGATIVE_VALUES arrays below for supported inputs.
package/dist/index.js CHANGED
@@ -168,7 +168,13 @@ async function measureExecutionTime(execution) {
168
168
 
169
169
  // src/validation/validation.refiners.ts
170
170
  import z2 from "zod";
171
- var asQueryNumber = (schema) => z2.preprocess((v) => typeof v === "string" ? Number(v) : v, schema);
171
+ var asQueryNumber = (schema) => z2.preprocess((value) => {
172
+ if (typeof value !== "string")
173
+ return value;
174
+ if (value.trim() === "")
175
+ return value;
176
+ return Number(value);
177
+ }, schema);
172
178
  var asQueryBoolean = (schema) => {
173
179
  const POSITIVE_VALUES = ["1", "true", "yes", "y", "on"];
174
180
  const NEGATIVE_VALUES = ["0", "false", "no", "n", "off"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "type": "module",
6
6
  "repository": {