payload-sanitizer 0.0.1 → 0.0.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/README.md +6 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# payload-sanitizer
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/payload-sanitizer)
|
|
4
|
+
[](https://www.npmjs.com/package/payload-sanitizer)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
3
7
|
Tiny zero‑dependency sanitizer for JS/TS payloads that removes common junk (empty strings, whitespace-only strings, `null`, `undefined`, optional dash marker, `NaN`) without mutating the original value. Works in both frontend and backend code.
|
|
4
8
|
|
|
5
9
|
## Install
|
|
@@ -57,6 +61,7 @@ const parsed = schema.parse(cleaned);
|
|
|
57
61
|
Returns a cleaned clone of `payload` (objects and arrays) without mutating the input.
|
|
58
62
|
|
|
59
63
|
**Options**
|
|
64
|
+
|
|
60
65
|
- `deep` (default `true`): recurse into nested objects.
|
|
61
66
|
- `trimStrings` (default `true`): `value.trim()` on strings before checks.
|
|
62
67
|
- `cleanArrays` (default `true`): sanitize array items and drop ones that should be removed.
|
|
@@ -67,6 +72,7 @@ Returns a cleaned clone of `payload` (objects and arrays) without mutating the i
|
|
|
67
72
|
- `shouldDrop(value, keyPath)`: custom predicate; return `true` to drop. `keyPath` is an array of keys/indexes from root.
|
|
68
73
|
|
|
69
74
|
Notes:
|
|
75
|
+
|
|
70
76
|
- `0`, `false`, and `""` inside `keepKeys` are preserved by design.
|
|
71
77
|
- If everything is dropped, arrays become `[]`, objects become `{}`; primitives are returned as-is.
|
|
72
78
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload-sanitizer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Tiny zero-dependency payload sanitizer for JS/TS (frontend + backend).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanitize",
|
|
@@ -44,5 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18"
|
|
47
50
|
}
|
|
48
51
|
}
|