@nemigo/helpers 0.3.1 → 0.3.2
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/xod.js +9 -6
- package/package.json +1 -1
package/dist/xod.js
CHANGED
|
@@ -43,12 +43,15 @@ export const numberSchema = z.unknown().transform((value, ctx) => caseNumber(val
|
|
|
43
43
|
: result));
|
|
44
44
|
export const numberSchemaOptional = z.union([nullSchema, numberSchema]);
|
|
45
45
|
//...
|
|
46
|
-
export const stringSchema = z.unknown().transform((value, ctx) => caseString(value, (result) =>
|
|
47
|
-
?
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
export const stringSchema = z.unknown().transform((value, ctx) => caseString(value, (result) => {
|
|
47
|
+
const trimmed = result === null ? "" : result.trim();
|
|
48
|
+
return trimmed === ""
|
|
49
|
+
? invalid(value, ctx, {
|
|
50
|
+
message: "It isn't a string or empty string",
|
|
51
|
+
expected: "string (or number)",
|
|
52
|
+
})
|
|
53
|
+
: trimmed;
|
|
54
|
+
}));
|
|
52
55
|
export const stringSchemaOptional = z.union([nullSchema, stringSchema]);
|
|
53
56
|
//...
|
|
54
57
|
export default {
|