@hy_ong/zod-kit 0.0.2 → 0.0.5

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.
Files changed (51) hide show
  1. package/.claude/settings.local.json +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +7 -7
  4. package/debug.js +21 -0
  5. package/debug.ts +16 -0
  6. package/dist/index.cjs +1663 -189
  7. package/dist/index.d.cts +324 -32
  8. package/dist/index.d.ts +324 -32
  9. package/dist/index.js +1634 -187
  10. package/eslint.config.mts +8 -0
  11. package/package.json +10 -9
  12. package/src/config.ts +1 -1
  13. package/src/i18n/locales/en.json +123 -49
  14. package/src/i18n/locales/zh-TW.json +123 -46
  15. package/src/index.ts +13 -7
  16. package/src/validators/common/boolean.ts +97 -0
  17. package/src/validators/common/date.ts +171 -0
  18. package/src/validators/common/email.ts +200 -0
  19. package/src/validators/common/id.ts +259 -0
  20. package/src/validators/common/number.ts +194 -0
  21. package/src/validators/common/password.ts +214 -0
  22. package/src/validators/common/text.ts +151 -0
  23. package/src/validators/common/url.ts +207 -0
  24. package/src/validators/taiwan/business-id.ts +140 -0
  25. package/src/validators/taiwan/fax.ts +182 -0
  26. package/src/validators/taiwan/mobile.ts +110 -0
  27. package/src/validators/taiwan/national-id.ts +208 -0
  28. package/src/validators/taiwan/tel.ts +182 -0
  29. package/tests/common/boolean.test.ts +340 -92
  30. package/tests/common/date.test.ts +458 -0
  31. package/tests/common/email.test.ts +232 -60
  32. package/tests/common/id.test.ts +535 -0
  33. package/tests/common/number.test.ts +230 -60
  34. package/tests/common/password.test.ts +281 -54
  35. package/tests/common/text.test.ts +227 -30
  36. package/tests/common/url.test.ts +492 -67
  37. package/tests/taiwan/business-id.test.ts +240 -0
  38. package/tests/taiwan/fax.test.ts +463 -0
  39. package/tests/taiwan/mobile.test.ts +373 -0
  40. package/tests/taiwan/national-id.test.ts +435 -0
  41. package/tests/taiwan/tel.test.ts +467 -0
  42. package/eslint.config.mjs +0 -10
  43. package/src/common/boolean.ts +0 -37
  44. package/src/common/date.ts +0 -44
  45. package/src/common/email.ts +0 -45
  46. package/src/common/integer.ts +0 -47
  47. package/src/common/number.ts +0 -38
  48. package/src/common/password.ts +0 -34
  49. package/src/common/text.ts +0 -35
  50. package/src/common/url.ts +0 -38
  51. package/tests/common/integer.test.ts +0 -90
@@ -0,0 +1,23 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm run build:*)",
5
+ "Bash(npm test)",
6
+ "Bash(npm test:*)",
7
+ "Bash(node:*)",
8
+ "Bash(cat:*)",
9
+ "WebSearch",
10
+ "WebFetch(domain:arthurdejong.org)",
11
+ "WebFetch(domain:wilhelmliao.wordpress.com)",
12
+ "WebFetch(domain:github.com)",
13
+ "Bash(npm run typecheck:*)",
14
+ "Bash(npm run:*)",
15
+ "Bash(npx tsc:*)",
16
+ "WebFetch(domain:www.motc.gov.tw)",
17
+ "WebFetch(domain:zh.wikipedia.org)",
18
+ "Bash(npx ts-node:*)"
19
+ ],
20
+ "deny": [],
21
+ "ask": []
22
+ }
23
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ong Hoe Yuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -19,7 +19,7 @@ npm install zod-kit
19
19
  ## Quick Start
20
20
 
21
21
  ```typescript
22
- import { email, password, text, number } from 'zod-kit'
22
+ import { email, password, text, number } from '@hy_ong/zod-kit'
23
23
 
24
24
  // Email validation
25
25
  const emailSchema = email({ label: 'Email' })
@@ -137,13 +137,13 @@ boolean({
137
137
  Set the locale for error messages:
138
138
 
139
139
  ```typescript
140
- import { setLocale } from 'zod-kit'
140
+ import { setLocale } from '@hy_ong/zod-kit'
141
141
 
142
- // Set to English (default is Traditional Chinese)
143
- setLocale('en')
144
-
145
- // Set to Traditional Chinese
142
+ // Set to Traditional Chinese (default is English)
146
143
  setLocale('zh-TW')
144
+
145
+ // Set to English (default)
146
+ setLocale('en')
147
147
  ```
148
148
 
149
149
  ## Optional Fields
@@ -176,7 +176,7 @@ npm run build
176
176
 
177
177
  ## License
178
178
 
179
- ISC
179
+ MIT
180
180
 
181
181
  ## Author
182
182
 
package/debug.js ADDED
@@ -0,0 +1,21 @@
1
+ // Debug test
2
+ import { tel } from './src/index.js'
3
+
4
+ const schema = tel()
5
+
6
+ // Test the exact numbers that work in utility test
7
+ const testNumbers = [
8
+ "0223456789", // Should work ✓
9
+ "072345678", // Should work ✓
10
+ "041234567", // Should work ✓
11
+ "031234567", // Testing this one
12
+ ]
13
+
14
+ for (const num of testNumbers) {
15
+ try {
16
+ const result = schema.parse(num)
17
+ console.log(`✓ ${num} -> ${result}`)
18
+ } catch (error) {
19
+ console.log(`✗ ${num} -> ${error.message}`)
20
+ }
21
+ }
package/debug.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { validateTaiwanTel } from './src/validators/taiwan/tel.js'
2
+
3
+ // Test the exact numbers from my area codes test
4
+ const testNumbers = [
5
+ "0223456789", // From my test - should work ✓
6
+ "0256789012", // From my test - testing this
7
+ "031234567", // From my test - testing this
8
+ "039876543", // From my test - testing this
9
+ "037234567", // From my test - testing this
10
+ "037987654", // From my test - testing this
11
+ ]
12
+
13
+ for (const num of testNumbers) {
14
+ const result = validateTaiwanTel(num)
15
+ console.log(`${result ? '✓' : '✗'} ${num}`)
16
+ }