typanic 1.0.1 → 1.0.3

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 CHANGED
@@ -41,6 +41,10 @@ Every helper takes the value and an optional `label` used in the error message
41
41
  | --- | --- | --- |
42
42
  | `forcedString(value, label?)` | `string` | throws unless `typeof value === "string"` |
43
43
  | `forcedInteger(value, label?)` | `number` | accepts integers and integer-looking strings (`"42"`) |
44
+ | `forcedIntegerFromString(value, label?)` | `number` | accepts safe decimal integer strings only; useful for form/query values |
45
+ | `forcedPositiveInteger(value, label?)` | `number` | accepts safe integers greater than zero and integer-looking strings (`"42"`) |
46
+ | `forcedPositiveIntegerFromString(value, label?)` | `number` | accepts safe positive decimal integer strings only |
47
+ | `forcedNonBlankString(value, label?)` | `string` | trims and rejects blank strings |
44
48
  | `forcedFloat(value, label?)` | `number` | accepts finite numbers and numeric strings; rejects `NaN`/`Infinity` |
45
49
  | `forcedBoolean(value, label?)` | `boolean` | does **not** coerce `"true"`/`1` — pass a real boolean |
46
50
 
@@ -50,6 +54,10 @@ Every helper takes the value and an optional `label` used in the error message
50
54
  | --- | --- |
51
55
  | `optionalString(value, label?)` | `string \| null` |
52
56
  | `optionalInteger(value, label?)` | `number \| null` |
57
+ | `optionalIntegerFromString(value, label?)` | `number \| null` |
58
+ | `optionalPositiveInteger(value, label?)` | `number \| null` |
59
+ | `optionalPositiveIntegerFromString(value, label?)` | `number \| null` |
60
+ | `optionalNonBlankString(value, label?)` | `string \| null` |
53
61
  | `optionalFloat(value, label?)` | `number \| null` |
54
62
  | `optionalBoolean(value, label?)` | `boolean \| null` |
55
63
 
@@ -58,11 +66,11 @@ Every helper takes the value and an optional `label` used in the error message
58
66
  different things.
59
67
 
60
68
  ```js
61
- import {forcedInteger, optionalString} from "typanic"
69
+ import {forcedPositiveIntegerFromString, optionalString} from "typanic"
62
70
 
63
- const cols = forcedInteger(payload.cols, "cols") // number, or throws
64
- const cursor = optionalString(payload.cursor, "cursor") // string | null
65
- const status = optionalString(payload.status, "status") ?? "ok" // default only when you truly need one
71
+ const cols = forcedPositiveIntegerFromString(payload.cols, "cols") // positive decimal string -> number, or throws
72
+ const cursor = optionalString(payload.cursor, "cursor") // string | null
73
+ const status = optionalString(payload.status, "status") ?? "ok" // default only when you truly need one
66
74
  ```
67
75
 
68
76
  ## Why "forced"?
package/build/index.d.ts CHANGED
@@ -35,6 +35,77 @@ export function forcedInteger(value: unknown, label?: string): number;
35
35
  * @returns {number | null} the integer value, or null when absent
36
36
  */
37
37
  export function optionalInteger(value: unknown, label?: string): number | null;
38
+ /**
39
+ * Returns a decimal integer parsed from a string, otherwise throws. Use this
40
+ * for form, route, or query values that must be strings before parsing.
41
+ *
42
+ * @param {unknown} value the value to assert
43
+ * @param {string} [label] name used in the thrown error message
44
+ * @returns {number} the value, parsed as a decimal integer
45
+ */
46
+ export function forcedIntegerFromString(value: unknown, label?: string): number;
47
+ /**
48
+ * Like {@link forcedIntegerFromString}, but allows the value to be absent
49
+ * (null/undefined become null). A present invalid value still throws.
50
+ *
51
+ * @param {unknown} value the value to assert
52
+ * @param {string} [label] name used in the thrown error message
53
+ * @returns {number | null} the parsed integer value, or null when absent
54
+ */
55
+ export function optionalIntegerFromString(value: unknown, label?: string): number | null;
56
+ /**
57
+ * Returns the value as a safe positive integer, otherwise throws. Numeric
58
+ * strings are parsed; zero, negatives, decimals, and unsafe integers throw.
59
+ *
60
+ * @param {unknown} value the value to assert
61
+ * @param {string} [label] name used in the thrown error message
62
+ * @returns {number} the value, typed as a safe positive integer
63
+ */
64
+ export function forcedPositiveInteger(value: unknown, label?: string): number;
65
+ /**
66
+ * Like {@link forcedPositiveInteger}, but allows the value to be absent
67
+ * (null/undefined become null). A present invalid value still throws.
68
+ *
69
+ * @param {unknown} value the value to assert
70
+ * @param {string} [label] name used in the thrown error message
71
+ * @returns {number | null} the positive integer value, or null when absent
72
+ */
73
+ export function optionalPositiveInteger(value: unknown, label?: string): number | null;
74
+ /**
75
+ * Returns a safe positive decimal integer parsed from a string, otherwise throws.
76
+ * Use this for form, route, or query values that must be strings before parsing.
77
+ *
78
+ * @param {unknown} value the value to assert
79
+ * @param {string} [label] name used in the thrown error message
80
+ * @returns {number} the value, parsed as a safe positive decimal integer
81
+ */
82
+ export function forcedPositiveIntegerFromString(value: unknown, label?: string): number;
83
+ /**
84
+ * Like {@link forcedPositiveIntegerFromString}, but allows the value to be absent
85
+ * (null/undefined become null). A present invalid value still throws.
86
+ *
87
+ * @param {unknown} value the value to assert
88
+ * @param {string} [label] name used in the thrown error message
89
+ * @returns {number | null} the parsed positive integer value, or null when absent
90
+ */
91
+ export function optionalPositiveIntegerFromString(value: unknown, label?: string): number | null;
92
+ /**
93
+ * Returns a trimmed string when it has non-whitespace content, otherwise throws.
94
+ *
95
+ * @param {unknown} value the value to assert
96
+ * @param {string} [label] name used in the thrown error message
97
+ * @returns {string} the trimmed non-blank string
98
+ */
99
+ export function forcedNonBlankString(value: unknown, label?: string): string;
100
+ /**
101
+ * Like {@link forcedNonBlankString}, but allows the value to be absent
102
+ * (null/undefined become null). Blank strings still throw when present.
103
+ *
104
+ * @param {unknown} value the value to assert
105
+ * @param {string} [label] name used in the thrown error message
106
+ * @returns {string | null} the trimmed non-blank string, or null when absent
107
+ */
108
+ export function optionalNonBlankString(value: unknown, label?: string): string | null;
38
109
  /**
39
110
  * Returns the value as a finite number, otherwise throws. Numeric strings are
40
111
  * parsed; everything else (including NaN and Infinity) throws.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,oCAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAQlB;AAED;;;;;;;GAOG;AACH,sCAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,qCAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;GAOG;AACH,uCAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,mCAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;GAOG;AACH,qCAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,qCAJW,OAAO,UACP,MAAM,GACJ,OAAO,CAQnB;AAED;;;;;;;GAOG;AACH,uCAJW,OAAO,UACP,MAAM,GACJ,OAAO,GAAG,IAAI,CAM1B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,oCAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAQlB;AAED;;;;;;;GAOG;AACH,sCAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,qCAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;GAOG;AACH,uCAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,+CAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAclB;AAED;;;;;;;GAOG;AACH,iDAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,6CAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;GAOG;AACH,+CAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,uDAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAclB;AAED;;;;;;;GAOG;AACH,yDAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;GAMG;AACH,4CAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAUlB;AAED;;;;;;;GAOG;AACH,8CAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,mCAJW,OAAO,UACP,MAAM,GACJ,MAAM,CAYlB;AAED;;;;;;;GAOG;AACH,qCAJW,OAAO,UACP,MAAM,GACJ,MAAM,GAAG,IAAI,CAMzB;AAED;;;;;;;GAOG;AACH,qCAJW,OAAO,UACP,MAAM,GACJ,OAAO,CAQnB;AAED;;;;;;;GAOG;AACH,uCAJW,OAAO,UACP,MAAM,GACJ,OAAO,GAAG,IAAI,CAM1B"}
package/build/index.js CHANGED
@@ -72,6 +72,127 @@ export function optionalInteger(value, label = "value") {
72
72
  return null;
73
73
  return forcedInteger(value, label);
74
74
  }
75
+ /**
76
+ * Returns a decimal integer parsed from a string, otherwise throws. Use this
77
+ * for form, route, or query values that must be strings before parsing.
78
+ *
79
+ * @param {unknown} value the value to assert
80
+ * @param {string} [label] name used in the thrown error message
81
+ * @returns {number} the value, parsed as a decimal integer
82
+ */
83
+ export function forcedIntegerFromString(value, label = "value") {
84
+ if (typeof value === "string") {
85
+ const trimmedValue = value.trim();
86
+ if (/^-?\d+$/.test(trimmedValue)) {
87
+ const parsedValue = Number.parseInt(trimmedValue, 10);
88
+ if (Number.isSafeInteger(parsedValue))
89
+ return parsedValue;
90
+ }
91
+ }
92
+ throw new TypeError(`Expected ${label} to be an integer string but got ${describeType(value)}`);
93
+ }
94
+ /**
95
+ * Like {@link forcedIntegerFromString}, but allows the value to be absent
96
+ * (null/undefined become null). A present invalid value still throws.
97
+ *
98
+ * @param {unknown} value the value to assert
99
+ * @param {string} [label] name used in the thrown error message
100
+ * @returns {number | null} the parsed integer value, or null when absent
101
+ */
102
+ export function optionalIntegerFromString(value, label = "value") {
103
+ if (value === null || value === undefined)
104
+ return null;
105
+ return forcedIntegerFromString(value, label);
106
+ }
107
+ /**
108
+ * Returns the value as a safe positive integer, otherwise throws. Numeric
109
+ * strings are parsed; zero, negatives, decimals, and unsafe integers throw.
110
+ *
111
+ * @param {unknown} value the value to assert
112
+ * @param {string} [label] name used in the thrown error message
113
+ * @returns {number} the value, typed as a safe positive integer
114
+ */
115
+ export function forcedPositiveInteger(value, label = "value") {
116
+ const parsedValue = typeof value === "number" || (typeof value === "string" && value.trim() !== "")
117
+ ? Number(value)
118
+ : Number.NaN;
119
+ if (!Number.isSafeInteger(parsedValue) || parsedValue < 1) {
120
+ throw new TypeError(`Expected ${label} to be a positive integer but got ${describeType(value)}`);
121
+ }
122
+ return parsedValue;
123
+ }
124
+ /**
125
+ * Like {@link forcedPositiveInteger}, but allows the value to be absent
126
+ * (null/undefined become null). A present invalid value still throws.
127
+ *
128
+ * @param {unknown} value the value to assert
129
+ * @param {string} [label] name used in the thrown error message
130
+ * @returns {number | null} the positive integer value, or null when absent
131
+ */
132
+ export function optionalPositiveInteger(value, label = "value") {
133
+ if (value === null || value === undefined)
134
+ return null;
135
+ return forcedPositiveInteger(value, label);
136
+ }
137
+ /**
138
+ * Returns a safe positive decimal integer parsed from a string, otherwise throws.
139
+ * Use this for form, route, or query values that must be strings before parsing.
140
+ *
141
+ * @param {unknown} value the value to assert
142
+ * @param {string} [label] name used in the thrown error message
143
+ * @returns {number} the value, parsed as a safe positive decimal integer
144
+ */
145
+ export function forcedPositiveIntegerFromString(value, label = "value") {
146
+ if (typeof value === "string") {
147
+ const trimmedValue = value.trim();
148
+ if (/^\d+$/.test(trimmedValue)) {
149
+ const parsedValue = Number.parseInt(trimmedValue, 10);
150
+ if (Number.isSafeInteger(parsedValue) && parsedValue > 0)
151
+ return parsedValue;
152
+ }
153
+ }
154
+ throw new TypeError(`Expected ${label} to be a positive integer string but got ${describeType(value)}`);
155
+ }
156
+ /**
157
+ * Like {@link forcedPositiveIntegerFromString}, but allows the value to be absent
158
+ * (null/undefined become null). A present invalid value still throws.
159
+ *
160
+ * @param {unknown} value the value to assert
161
+ * @param {string} [label] name used in the thrown error message
162
+ * @returns {number | null} the parsed positive integer value, or null when absent
163
+ */
164
+ export function optionalPositiveIntegerFromString(value, label = "value") {
165
+ if (value === null || value === undefined)
166
+ return null;
167
+ return forcedPositiveIntegerFromString(value, label);
168
+ }
169
+ /**
170
+ * Returns a trimmed string when it has non-whitespace content, otherwise throws.
171
+ *
172
+ * @param {unknown} value the value to assert
173
+ * @param {string} [label] name used in the thrown error message
174
+ * @returns {string} the trimmed non-blank string
175
+ */
176
+ export function forcedNonBlankString(value, label = "value") {
177
+ const stringValue = forcedString(value, label).trim();
178
+ if (!stringValue) {
179
+ throw new TypeError(`Expected ${label} to be a non-blank string but got ${describeType(value)}`);
180
+ }
181
+ return stringValue;
182
+ }
183
+ /**
184
+ * Like {@link forcedNonBlankString}, but allows the value to be absent
185
+ * (null/undefined become null). Blank strings still throw when present.
186
+ *
187
+ * @param {unknown} value the value to assert
188
+ * @param {string} [label] name used in the thrown error message
189
+ * @returns {string | null} the trimmed non-blank string, or null when absent
190
+ */
191
+ export function optionalNonBlankString(value, label = "value") {
192
+ if (value === null || value === undefined)
193
+ return null;
194
+ return forcedNonBlankString(value, label);
195
+ }
75
196
  /**
76
197
  * Returns the value as a finite number, otherwise throws. Numeric strings are
77
198
  * parsed; everything else (including NaN and Infinity) throws.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,YAAY;AAEZ;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAK;IACzB,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAA;IACjC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAA;IAE3C,OAAO,OAAO,KAAK,CAAA;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,YAAY,KAAK,2BAA2B,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAA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AAK,EAAE,KAAK,GAAG,OAAO;IAClD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,YAAY,KAAK,4BAA4B,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACzF,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IACpD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAA;IAEtD,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typanic",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Forced runtime type assertions for untrusted input — get the type you expect or throw, instead of silently coercing a wrong value to \"\" / 0 / false.",
5
5
  "keywords": [
6
6
  "type",
@@ -46,13 +46,14 @@
46
46
  "LICENSE"
47
47
  ],
48
48
  "scripts": {
49
- "all-checks": "npm run lint && npm run typecheck && npm test",
49
+ "all-checks": "npm run lint && npm test",
50
50
  "build": "tsc --project tsconfig.json",
51
- "lint": "eslint .",
51
+ "lint": "npm run eslint && npm run typecheck",
52
52
  "prepare": "npm run build",
53
53
  "release:patch": "release-patch",
54
54
  "test": "jasmine",
55
- "typecheck": "tsc --project tsconfig.json --noEmit"
55
+ "typecheck": "tsc --project tsconfig.json --noEmit",
56
+ "eslint": "eslint ."
56
57
  },
57
58
  "devDependencies": {
58
59
  "@eslint/js": "^10.0.1",