@oxog/vld 1.4.0 → 1.5.0

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 (187) hide show
  1. package/CHANGELOG.md +333 -333
  2. package/README.md +1130 -1130
  3. package/dist/cli/benchmark.d.ts +15 -0
  4. package/dist/cli/benchmark.d.ts.map +1 -0
  5. package/dist/cli/benchmark.js +248 -0
  6. package/dist/cli/benchmark.js.map +1 -0
  7. package/dist/cli/bin.d.ts +8 -0
  8. package/dist/cli/bin.d.ts.map +1 -0
  9. package/dist/cli/bin.js +35 -0
  10. package/dist/cli/bin.js.map +1 -0
  11. package/dist/cli/commands/benchmark.d.ts +11 -0
  12. package/dist/cli/commands/benchmark.d.ts.map +1 -0
  13. package/dist/cli/commands/benchmark.js +204 -0
  14. package/dist/cli/commands/benchmark.js.map +1 -0
  15. package/dist/cli/commands/validate.d.ts +11 -0
  16. package/dist/cli/commands/validate.d.ts.map +1 -0
  17. package/dist/cli/commands/validate.js +157 -0
  18. package/dist/cli/commands/validate.js.map +1 -0
  19. package/dist/cli/generate.d.ts +14 -0
  20. package/dist/cli/generate.d.ts.map +1 -0
  21. package/dist/cli/generate.js +233 -0
  22. package/dist/cli/generate.js.map +1 -0
  23. package/dist/cli/index.d.ts +59 -0
  24. package/dist/cli/index.d.ts.map +1 -0
  25. package/dist/cli/index.js +182 -0
  26. package/dist/cli/index.js.map +1 -0
  27. package/dist/cli/validate.d.ts +15 -0
  28. package/dist/cli/validate.d.ts.map +1 -0
  29. package/dist/cli/validate.js +162 -0
  30. package/dist/cli/validate.js.map +1 -0
  31. package/dist/codecs/index.d.ts.map +1 -1
  32. package/dist/codecs/index.js +29 -10
  33. package/dist/codecs/index.js.map +1 -1
  34. package/dist/coercion/boolean.d.ts.map +1 -1
  35. package/dist/coercion/boolean.js +23 -31
  36. package/dist/coercion/boolean.js.map +1 -1
  37. package/dist/coercion/date.js +1 -1
  38. package/dist/coercion/date.js.map +1 -1
  39. package/dist/compat/emitter.d.ts +73 -0
  40. package/dist/compat/emitter.d.ts.map +1 -0
  41. package/dist/compat/emitter.js +179 -0
  42. package/dist/compat/emitter.js.map +1 -0
  43. package/dist/compat/index.d.ts +15 -0
  44. package/dist/compat/index.d.ts.map +1 -0
  45. package/dist/compat/index.js +14 -0
  46. package/dist/compat/index.js.map +1 -0
  47. package/dist/compat/result.d.ts +128 -0
  48. package/dist/compat/result.d.ts.map +1 -0
  49. package/dist/compat/result.js +169 -0
  50. package/dist/compat/result.js.map +1 -0
  51. package/dist/errors.d.ts +58 -1
  52. package/dist/errors.d.ts.map +1 -1
  53. package/dist/errors.js +97 -9
  54. package/dist/errors.js.map +1 -1
  55. package/dist/events.d.ts +140 -0
  56. package/dist/events.d.ts.map +1 -0
  57. package/dist/events.js +8 -0
  58. package/dist/events.js.map +1 -0
  59. package/dist/guards.d.ts +143 -0
  60. package/dist/guards.d.ts.map +1 -0
  61. package/dist/guards.js +238 -0
  62. package/dist/guards.js.map +1 -0
  63. package/dist/index-new.d.ts.map +1 -0
  64. package/dist/index.d.ts +13 -1
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +29 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/kernel.d.ts +29 -0
  69. package/dist/kernel.d.ts.map +1 -0
  70. package/dist/kernel.js +402 -0
  71. package/dist/kernel.js.map +1 -0
  72. package/dist/locales/af.js.map +1 -1
  73. package/dist/locales/ar.js.map +1 -1
  74. package/dist/locales/backup-en.js.map +1 -1
  75. package/dist/locales/bn.js.map +1 -1
  76. package/dist/locales/da.js.map +1 -1
  77. package/dist/locales/de.js.map +1 -1
  78. package/dist/locales/en.js.map +1 -1
  79. package/dist/locales/es-MX.js.map +1 -1
  80. package/dist/locales/es.js.map +1 -1
  81. package/dist/locales/fi.js.map +1 -1
  82. package/dist/locales/fr.js.map +1 -1
  83. package/dist/locales/hi.js.map +1 -1
  84. package/dist/locales/id.js.map +1 -1
  85. package/dist/locales/it.js.map +1 -1
  86. package/dist/locales/ja.js.map +1 -1
  87. package/dist/locales/ko.js.map +1 -1
  88. package/dist/locales/nl.js.map +1 -1
  89. package/dist/locales/no.js.map +1 -1
  90. package/dist/locales/pl.js.map +1 -1
  91. package/dist/locales/pt-BR.js.map +1 -1
  92. package/dist/locales/pt.js.map +1 -1
  93. package/dist/locales/ru.js.map +1 -1
  94. package/dist/locales/sv.js.map +1 -1
  95. package/dist/locales/sw.js.map +1 -1
  96. package/dist/locales/th.js.map +1 -1
  97. package/dist/locales/tr.js.map +1 -1
  98. package/dist/locales/types.js.map +1 -1
  99. package/dist/locales/vi.js.map +1 -1
  100. package/dist/locales/zh.js.map +1 -1
  101. package/dist/locales.d.ts +54 -0
  102. package/dist/locales.d.ts.map +1 -0
  103. package/dist/locales.js +732 -0
  104. package/dist/locales.js.map +1 -0
  105. package/dist/logger.d.ts +94 -0
  106. package/dist/logger.d.ts.map +1 -0
  107. package/dist/logger.js +184 -0
  108. package/dist/logger.js.map +1 -0
  109. package/dist/pigment.d.ts +124 -0
  110. package/dist/pigment.d.ts.map +1 -0
  111. package/dist/pigment.js +177 -0
  112. package/dist/pigment.js.map +1 -0
  113. package/dist/plugins/codecs.d.ts +17 -0
  114. package/dist/plugins/codecs.d.ts.map +1 -0
  115. package/dist/plugins/codecs.js +29 -0
  116. package/dist/plugins/codecs.js.map +1 -0
  117. package/dist/plugins/coercion.d.ts +13 -0
  118. package/dist/plugins/coercion.d.ts.map +1 -0
  119. package/dist/plugins/coercion.js +34 -0
  120. package/dist/plugins/coercion.js.map +1 -0
  121. package/dist/plugins/core-validators.d.ts +13 -0
  122. package/dist/plugins/core-validators.d.ts.map +1 -0
  123. package/dist/plugins/core-validators.js +96 -0
  124. package/dist/plugins/core-validators.js.map +1 -0
  125. package/dist/plugins/index.d.ts +8 -0
  126. package/dist/plugins/index.d.ts.map +1 -0
  127. package/dist/plugins/index.js +8 -0
  128. package/dist/plugins/index.js.map +1 -0
  129. package/dist/plugins/kernel.d.ts +29 -0
  130. package/dist/plugins/kernel.d.ts.map +1 -0
  131. package/dist/plugins/kernel.js +486 -0
  132. package/dist/plugins/kernel.js.map +1 -0
  133. package/dist/plugins/types.d.ts +186 -0
  134. package/dist/plugins/types.d.ts.map +1 -0
  135. package/dist/plugins/types.js +8 -0
  136. package/dist/plugins/types.js.map +1 -0
  137. package/dist/style.d.ts +123 -0
  138. package/dist/style.d.ts.map +1 -0
  139. package/dist/style.js +369 -0
  140. package/dist/style.js.map +1 -0
  141. package/dist/utils/codec-utils.d.ts.map +1 -1
  142. package/dist/utils/codec-utils.js +6 -0
  143. package/dist/utils/codec-utils.js.map +1 -1
  144. package/dist/utils/ip-validation.d.ts.map +1 -1
  145. package/dist/utils/ip-validation.js +34 -14
  146. package/dist/utils/ip-validation.js.map +1 -1
  147. package/dist/validators/base.d.ts +3 -0
  148. package/dist/validators/base.d.ts.map +1 -1
  149. package/dist/validators/base.js +8 -0
  150. package/dist/validators/base.js.map +1 -1
  151. package/dist/validators/bigint.js.map +1 -1
  152. package/dist/validators/custom.js.map +1 -1
  153. package/dist/validators/discriminated-union.js.map +1 -1
  154. package/dist/validators/file.js.map +1 -1
  155. package/dist/validators/function.js.map +1 -1
  156. package/dist/validators/index.js.map +1 -1
  157. package/dist/validators/json.js.map +1 -1
  158. package/dist/validators/lazy.js.map +1 -1
  159. package/dist/validators/nan.js.map +1 -1
  160. package/dist/validators/null.js.map +1 -1
  161. package/dist/validators/object-optimized.d.ts +23 -0
  162. package/dist/validators/object-optimized.d.ts.map +1 -0
  163. package/dist/validators/object-optimized.js +179 -0
  164. package/dist/validators/object-optimized.js.map +1 -0
  165. package/dist/validators/object-ultra.d.ts +34 -0
  166. package/dist/validators/object-ultra.d.ts.map +1 -0
  167. package/dist/validators/object-ultra.js +175 -0
  168. package/dist/validators/object-ultra.js.map +1 -0
  169. package/dist/validators/object.d.ts.map +1 -1
  170. package/dist/validators/object.js +1 -1
  171. package/dist/validators/object.js.map +1 -1
  172. package/dist/validators/string-bool.js.map +1 -1
  173. package/dist/validators/string-formats.js.map +1 -1
  174. package/dist/validators/string-ultra.d.ts +49 -0
  175. package/dist/validators/string-ultra.d.ts.map +1 -0
  176. package/dist/validators/string-ultra.js +217 -0
  177. package/dist/validators/string-ultra.js.map +1 -0
  178. package/dist/validators/template-literal.d.ts.map +1 -1
  179. package/dist/validators/template-literal.js +13 -12
  180. package/dist/validators/template-literal.js.map +1 -1
  181. package/dist/validators/undefined.js.map +1 -1
  182. package/dist/validators/union-optimized.d.ts +15 -0
  183. package/dist/validators/union-optimized.d.ts.map +1 -0
  184. package/dist/validators/union-optimized.js +92 -0
  185. package/dist/validators/union-optimized.js.map +1 -0
  186. package/dist/validators/xor.js.map +1 -1
  187. package/package.json +95 -79
package/CHANGELOG.md CHANGED
@@ -1,334 +1,334 @@
1
- # Changelog
2
-
3
- All notable changes to VLD will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.4.0] - 2026-01-02
9
-
10
- ### 🚀 **Zod 4 Full API Parity Achieved**
11
- - **Complete Feature Set**: 100% Zod 4 API compatibility
12
- - **1142 Tests Passing**: Comprehensive test coverage across all features
13
- - **Production Ready**: All validators, codecs, and utilities fully tested
14
-
15
- ### ✨ New Features
16
-
17
- #### **v.cidrv6() - IPv6 CIDR Block Validator**
18
- New validator for IPv6 CIDR notation validation:
19
- - Supports full IPv6 addresses with prefix lengths (0-128)
20
- - Validates compressed IPv6 notation (`::`, `::1`, etc.)
21
- - Rejects IPv4 CIDR blocks
22
-
23
- #### **.apply() - External Function Chaining**
24
- Apply external functions to validators for advanced composition:
25
- - Enables functional composition patterns
26
- - Supports custom validation pipelines
27
- - Full TypeScript type inference
28
-
29
- #### **.safeExtend() - Type-Safe Object Extension**
30
- Safely extend object schemas without accidentally overriding existing fields:
31
- - Prevents accidental field overrides in object schemas
32
- - Clear error messages listing all conflicting keys
33
- - Supports chaining multiple safeExtend calls
34
-
35
- ### 🌍 Internationalization Updates
36
- - Added i18n messages for all new features in **27+ languages**
37
- - New messages: `stringCidrv6`, `safeExtendOverlap`
38
- - Updated all locale files with translations
39
-
40
- ### 🔧 Build System Improvements
41
- - **Fixed ESM module resolution**: Directory imports now correctly resolve to `/index.js`
42
- - **Updated fix-imports script**: Now handles directory-based imports properly
43
- - **Renamed to CommonJS**: `scripts/fix-imports.cjs` for ESM package compatibility
44
-
45
- ### 📊 Performance
46
- VLD continues to outperform Zod across all benchmarks:
47
- - **2.52x faster** average performance
48
- - **9/10 benchmark wins** vs Zod
49
- - **2.41x less memory** usage overall
50
- - **83x faster** schema creation
51
-
52
- ### 🧪 Testing
53
- - **49 test suites** - All passing
54
- - **1142 tests** - Comprehensive coverage
55
- - **TypeScript strict mode** - Full type safety verified
56
-
57
- ## [1.3.1] - 2025-11-12
58
-
59
- ### 🎯 **100% Test Success Rate Achieved**
60
- - **Perfect Test Coverage**: All 695 tests now passing (0 failures)
61
- - **IPv6 Validation Fix**: Resolved final failing test for IPv6-mapped addresses
62
- - **Security Validation**: All 4 critical security fixes thoroughly tested
63
-
64
- ### 🔧 Bug Fixes
65
- - **IPv6 Validation**: Fixed validation for IPv4-mapped IPv6 addresses (`::ffff:192.0.2.1`)
66
- - **Test Coverage**: Updated documentation to reflect 695 passing tests (up from 694)
67
-
68
- ### ✅ Quality Assurance
69
- - **100% Test Success**: Achieved perfect test success rate across all test suites
70
- - **Security Hardening**: All security vulnerabilities validated with comprehensive tests
71
- - **Performance Maintained**: No performance impact from security improvements
72
-
73
- ## [1.3.0] - 2025-11-12
74
-
75
- ### 🔒 **Critical Security Update**
76
- - **SECURITY**: Fixed 4 critical security vulnerabilities identified in comprehensive bug analysis
77
- - **Enhanced Security**: Comprehensive protection against prototype pollution, ReDoS attacks, and type safety issues
78
- - **Security-First**: All validators now include security controls while maintaining backwards compatibility
79
-
80
- ### 🛡️ Security Fixes Implemented
81
-
82
- #### **BUG-001: Union Validator Type Safety** ✅ FIXED
83
- - **Issue**: Constructor name spoofing vulnerability in union validators
84
- - **Solution**: Replaced constructor name checking with secure feature detection
85
- - **Impact**: Prevents malicious validator objects from bypassing type checks
86
- - **Location**: `src/validators/union.ts`
87
-
88
- #### **BUG-002: Prototype Pollution Prevention** ✅ FIXED
89
- - **Issue**: Prototype pollution vulnerability in codec utilities
90
- - **Solution**: Added comprehensive input validation and suspicious content detection
91
- - **Impact**: Prevents `__proto__`, `constructor`, and `prototype` pollution attacks
92
- - **Location**: `src/utils/codec-utils.ts`
93
-
94
- #### **BUG-004: IPv6 ReDoS Prevention** ✅ FIXED
95
- - **Issue**: Regular Expression Denial of Service (ReDoS) vulnerability in IPv6 validation
96
- - **Solution**: Replaced complex regex with multi-step validation approach
97
- - **Impact**: Prevents catastrophic backtracking attacks while maintaining IPv6 support
98
- - **Location**: `src/validators/string.ts`, `src/coercion/string.ts`
99
-
100
- #### **BUG-005: Safe String Coercion** ✅ FIXED
101
- - **Issue**: Unsafe type coercion without length limits or sanitization
102
- - **Solution**: Added length limits (1M characters) and control character sanitization
103
- - **Impact**: Prevents DoS attacks and information disclosure through malicious strings
104
- - **Location**: `src/coercion/string.ts`
105
-
106
- ### 📊 Quality Improvements
107
- - **Test Coverage**: Maintained excellent coverage at **96.55%** with **695 passing tests**
108
- - **Performance**: All security improvements maintain VLD's performance advantages
109
- - **Backwards Compatibility**: All changes are fully backwards compatible
110
- - **Security Testing**: Comprehensive security test suite added with 18 dedicated tests
111
-
112
- ### 🧪 Testing & Validation
113
- - **Security Test Suite**: Added comprehensive security validation tests
114
- - **Performance Tests**: Verified security fixes don't impact performance
115
- - **Integration Tests**: Validated compatibility with existing codebases
116
- - **Memory Tests**: Confirmed no memory leaks with security enhancements
117
-
118
- ### 📝 Documentation Updates
119
- - **Security Documentation**: Detailed security analysis reports created
120
- - **Bug Fix Reports**: Comprehensive documentation of all fixes implemented
121
- - **Test Coverage**: Updated coverage metrics to reflect new security tests
122
- - **README**: Updated to reflect latest test coverage and security improvements
123
-
124
- ### 🔧 Technical Details
125
- - **Zero Breaking Changes**: All security improvements are backwards compatible
126
- - **Immutable Architecture**: Security hardening maintains VLD's immutable validator pattern
127
- - **Type Safety**: Enhanced type checking without compromising TypeScript inference
128
- - **Error Handling**: Improved error messages for security-related validation failures
129
-
130
- ## [1.2.0] - 2025-08-24
131
-
132
- ### 🎯 **100% Test Success Rate Achieved**
133
- - **569 tests passing** with 0 failures across all test suites
134
- - **97.3% statement coverage** (up from 97.18%)
135
- - **93.5% branch coverage**
136
- - **96.78% function coverage**
137
- - **97.6% line coverage**
138
- - All Zod-compatible codec tests now fully passing
139
-
140
- ### 🚀 Major Features Added
141
-
142
- #### **Codec System - Bidirectional Transformations**
143
- - **NEW**: Complete codec system for bidirectional data transformations
144
- - `v.codec()` factory method for creating custom codecs
145
- - Full encode/decode support with type safety
146
- - Async codec support with `parseAsync()` and `encodeAsync()` methods
147
- - Comprehensive error handling for both directions
148
-
149
- #### **19 Built-in Zod-Compatible Codecs**
150
-
151
- **String Conversion Codecs:**
152
- - `stringToNumber` - String ↔ Number with validation
153
- - `stringToInt` - String ↔ Integer with validation
154
- - `stringToBigInt` - String ↔ BigInt conversion
155
- - `numberToBigInt` - Number ↔ BigInt conversion
156
- - `stringToBoolean` - Flexible string ↔ boolean (`'true'`, `'1'`, `'yes'`, `'on'` → `true`)
157
-
158
- **Date Conversion Codecs:**
159
- - `isoDatetimeToDate` - ISO 8601 string ↔ Date object
160
- - `epochSecondsToDate` - Unix seconds ↔ Date object
161
- - `epochMillisToDate` - Unix milliseconds ↔ Date object
162
-
163
- **JSON and Complex Data:**
164
- - `jsonCodec()` - Generic JSON string ↔ any type
165
- - `base64Json()` - Base64-encoded JSON with schema validation
166
- - `jwtPayload()` - JWT payload decoder (read-only)
167
-
168
- **URL and Web:**
169
- - `stringToURL` - String ↔ URL object
170
- - `stringToHttpURL` - HTTP/HTTPS URL validation and conversion
171
- - `uriComponent` - URI component encode/decode
172
-
173
- **Binary Data:**
174
- - `base64ToBytes` - Base64 ↔ Uint8Array
175
- - `base64urlToBytes` - URL-safe Base64 ↔ Uint8Array
176
- - `hexToBytes` - Hexadecimal ↔ Uint8Array
177
- - `utf8ToBytes` - UTF-8 string ↔ Uint8Array
178
- - `bytesToUtf8` - Uint8Array ↔ UTF-8 string
179
-
180
- #### **New Validator Types**
181
- - `v.base64()` - Base64 string validation with URL-safe mode
182
- - `v.hex()` - Hexadecimal string validation with lowercase mode
183
- - `v.uint8Array()` - Uint8Array validation with length constraints
184
-
185
- #### **Enhanced Utilities**
186
- - Comprehensive codec utility functions in `codec-utils.ts`
187
- - Cross-platform Base64 encoding/decoding (Node.js + Browser)
188
- - Secure error handling for all codec operations
189
-
190
- ### 📚 Documentation Updates
191
- - **README.md**: Comprehensive codec documentation with examples
192
- - **API.md**: Complete codec API reference with TypeScript examples
193
- - **New Examples**:
194
- - `examples/codecs.js` - JavaScript codec examples
195
- - `examples/codecs.ts` - TypeScript codec examples with full type safety
196
- - Updated CLAUDE.md with codec development guidance
197
-
198
- ### 🔧 Technical Improvements
199
- - **Zero Circular Dependencies**: Refactored codec architecture
200
- - **Full Type Safety**: Complete TypeScript support with inference
201
- - **97.3% Test Coverage**: Comprehensive test suite with 569 passing tests
202
- - **Error Message Localization**: All codec errors support 27+ languages
203
-
204
- ### 🎯 Zod Compatibility
205
- - **100% Zod Codec Parity**: All Zod codecs implemented and compatible
206
- - **Beyond Zod**: Additional codecs not available in Zod
207
- - **Drop-in Replacement**: Seamless migration path from Zod codecs
208
-
209
- ### Performance
210
- - **Optimized Transformations**: Efficient bidirectional conversions
211
- - **Memory Efficient**: Immutable codec architecture prevents leaks
212
- - **Async Support**: Non-blocking operations for I/O-bound transformations
213
-
214
- ## [1.1.1] - 2025-08-18
215
-
216
- ### Security
217
- - **CRITICAL**: Fixed prototype pollution vulnerability in VldObject passthrough mode
218
- - Added protection against `__proto__`, `constructor`, and `prototype` key pollution
219
- - Comprehensive security test suite added
220
-
221
- ### Fixed
222
- - Removed unnecessary escape characters in regex patterns (URL validation)
223
- - Fixed escape characters in locale files (Afrikaans)
224
- - Added ESLint configuration for code quality
225
-
226
- ### Added
227
- - Security test suite with prototype pollution prevention tests
228
- - Coverage improvement tests for better code quality
229
- - ESLint configuration with TypeScript support
230
-
231
- ### Changed
232
- - Improved test coverage to 97.1% statements
233
- - All linting issues resolved
234
-
235
- ## [1.1.0] - 2025-08-12
236
-
237
- ### Added
238
- - Professional benchmark suite with real-world performance testing
239
- - `benchmarks/quick-bench.cjs` - Fast performance comparison
240
- - `benchmarks/memory.cjs` - Memory usage analysis
241
- - `benchmarks/startup.cjs` - Startup time comparison
242
- - `benchmarks/performance.cjs` - Comprehensive benchmark suite
243
- - Complete documentation overhaul in `/docs` folder:
244
- - `API.md` - Full API reference with all methods and examples
245
- - `GETTING_STARTED.md` - Beginner-friendly guide
246
- - `MIGRATION.md` - Step-by-step Zod to VLD migration
247
- - `PERFORMANCE.md` - Performance optimization guide
248
- - `ADVANCED_FEATURES.md` - Deep dive into advanced features
249
-
250
- ### Changed
251
- - Updated README with accurate benchmark results showing 2.07x average improvement
252
- - All documentation converted to English
253
- - Improved build process with automatic ES module import fixes
254
- - Test coverage increased to 99.5%
255
- - Cleaned up project structure for better maintainability
256
-
257
- ### Removed
258
- - Deleted `coverage/` folder (unnecessary for npm package)
259
- - Removed 12 old benchmark files
260
- - Cleaned up `src/errors/` and `src/types/` folders
261
- - Removed redundant test files focused on coverage metrics
262
- - Deleted unnecessary example files
263
-
264
- ### Fixed
265
- - Fixed ES module import issues with `.js` extension resolver
266
- - Resolved CommonJS compatibility for benchmark files
267
- - Fixed all TypeScript compilation errors
268
- - Corrected package.json export configurations
269
-
270
- ### Performance
271
- - Memory usage: 86% less than Zod
272
- - Startup time: 1.94x faster
273
- - Schema creation: 8.22x faster
274
- - Overall performance: 2.07x faster average
275
-
276
- ## [1.0.0] - 2025-08-11
277
-
278
- ### Initial Release
279
-
280
- #### Core Features
281
- - **Blazing Fast Performance**: 2-4x faster than Zod in most operations
282
- - **Zero Dependencies**: Lightweight with no external packages
283
- - **Full TypeScript Support**: Excellent type inference and IntelliSense
284
- - **Zod API Compatibility**: Drop-in replacement with identical API
285
- - **Tree-Shakeable**: Only import what you need
286
-
287
- #### Validation Types
288
- - **Primitives**: string, number, boolean, bigint, symbol, date, undefined, null, void, any, unknown, never
289
- - **Collections**: array, tuple, object, record, map, set
290
- - **Compositions**: union, intersection, literal, enum
291
- - **Modifiers**: optional, nullable, nullish, default, catch
292
-
293
- #### Advanced Features
294
- - **Type Coercion**: Automatic type conversion for common cases
295
- - **Custom Validation**: `refine()` and `superRefine()` for custom logic
296
- - **Data Transformation**: `transform()` for post-validation processing
297
- - **Object Utilities**: `pick()`, `omit()`, `extend()`, `merge()`, `partial()`
298
- - **Error Formatting**: Tree, pretty, and flatten utilities
299
-
300
- #### Internationalization
301
- - Built-in support for 27+ languages
302
- - Easy locale switching with `setLocale()`
303
- - Comprehensive translation coverage
304
-
305
- #### String Validators
306
- - Email, URL, UUID validation
307
- - IP address (v4/v6) validation
308
- - Regex pattern matching
309
- - Length constraints (min, max, length)
310
- - Content checks (includes, startsWith, endsWith)
311
- - Transformations (trim, toLowerCase, toUpperCase)
312
-
313
- #### Number Validators
314
- - Range validation (min, max)
315
- - Type constraints (int, positive, negative, finite, safe)
316
- - Mathematical checks (multipleOf)
317
-
318
- #### Performance Optimizations
319
- - Optimized for V8 JavaScript engine
320
- - Minimal memory allocations
321
- - Fast-path optimizations for common cases
322
- - Immutable validators prevent memory leaks
323
- - Pre-computed validation strategies
324
-
325
- #### Developer Experience
326
- - Clear, actionable error messages
327
- - Comprehensive test suite (99.5% coverage)
328
- - Extensive documentation and examples
329
- - TypeScript-first design
330
- - Intuitive, chainable API
331
-
332
- ---
333
-
1
+ # Changelog
2
+
3
+ All notable changes to VLD will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.4.0] - 2026-01-02
9
+
10
+ ### 🚀 **Zod 4 Full API Parity Achieved**
11
+ - **Complete Feature Set**: 100% Zod 4 API compatibility
12
+ - **1142 Tests Passing**: Comprehensive test coverage across all features
13
+ - **Production Ready**: All validators, codecs, and utilities fully tested
14
+
15
+ ### ✨ New Features
16
+
17
+ #### **v.cidrv6() - IPv6 CIDR Block Validator**
18
+ New validator for IPv6 CIDR notation validation:
19
+ - Supports full IPv6 addresses with prefix lengths (0-128)
20
+ - Validates compressed IPv6 notation (`::`, `::1`, etc.)
21
+ - Rejects IPv4 CIDR blocks
22
+
23
+ #### **.apply() - External Function Chaining**
24
+ Apply external functions to validators for advanced composition:
25
+ - Enables functional composition patterns
26
+ - Supports custom validation pipelines
27
+ - Full TypeScript type inference
28
+
29
+ #### **.safeExtend() - Type-Safe Object Extension**
30
+ Safely extend object schemas without accidentally overriding existing fields:
31
+ - Prevents accidental field overrides in object schemas
32
+ - Clear error messages listing all conflicting keys
33
+ - Supports chaining multiple safeExtend calls
34
+
35
+ ### 🌍 Internationalization Updates
36
+ - Added i18n messages for all new features in **27+ languages**
37
+ - New messages: `stringCidrv6`, `safeExtendOverlap`
38
+ - Updated all locale files with translations
39
+
40
+ ### 🔧 Build System Improvements
41
+ - **Fixed ESM module resolution**: Directory imports now correctly resolve to `/index.js`
42
+ - **Updated fix-imports script**: Now handles directory-based imports properly
43
+ - **Renamed to CommonJS**: `scripts/fix-imports.cjs` for ESM package compatibility
44
+
45
+ ### 📊 Performance
46
+ VLD continues to outperform Zod across all benchmarks:
47
+ - **2.52x faster** average performance
48
+ - **9/10 benchmark wins** vs Zod
49
+ - **2.41x less memory** usage overall
50
+ - **83x faster** schema creation
51
+
52
+ ### 🧪 Testing
53
+ - **49 test suites** - All passing
54
+ - **1142 tests** - Comprehensive coverage
55
+ - **TypeScript strict mode** - Full type safety verified
56
+
57
+ ## [1.3.1] - 2025-11-12
58
+
59
+ ### 🎯 **100% Test Success Rate Achieved**
60
+ - **Perfect Test Coverage**: All 695 tests now passing (0 failures)
61
+ - **IPv6 Validation Fix**: Resolved final failing test for IPv6-mapped addresses
62
+ - **Security Validation**: All 4 critical security fixes thoroughly tested
63
+
64
+ ### 🔧 Bug Fixes
65
+ - **IPv6 Validation**: Fixed validation for IPv4-mapped IPv6 addresses (`::ffff:192.0.2.1`)
66
+ - **Test Coverage**: Updated documentation to reflect 695 passing tests (up from 694)
67
+
68
+ ### ✅ Quality Assurance
69
+ - **100% Test Success**: Achieved perfect test success rate across all test suites
70
+ - **Security Hardening**: All security vulnerabilities validated with comprehensive tests
71
+ - **Performance Maintained**: No performance impact from security improvements
72
+
73
+ ## [1.3.0] - 2025-11-12
74
+
75
+ ### 🔒 **Critical Security Update**
76
+ - **SECURITY**: Fixed 4 critical security vulnerabilities identified in comprehensive bug analysis
77
+ - **Enhanced Security**: Comprehensive protection against prototype pollution, ReDoS attacks, and type safety issues
78
+ - **Security-First**: All validators now include security controls while maintaining backwards compatibility
79
+
80
+ ### 🛡️ Security Fixes Implemented
81
+
82
+ #### **BUG-001: Union Validator Type Safety** ✅ FIXED
83
+ - **Issue**: Constructor name spoofing vulnerability in union validators
84
+ - **Solution**: Replaced constructor name checking with secure feature detection
85
+ - **Impact**: Prevents malicious validator objects from bypassing type checks
86
+ - **Location**: `src/validators/union.ts`
87
+
88
+ #### **BUG-002: Prototype Pollution Prevention** ✅ FIXED
89
+ - **Issue**: Prototype pollution vulnerability in codec utilities
90
+ - **Solution**: Added comprehensive input validation and suspicious content detection
91
+ - **Impact**: Prevents `__proto__`, `constructor`, and `prototype` pollution attacks
92
+ - **Location**: `src/utils/codec-utils.ts`
93
+
94
+ #### **BUG-004: IPv6 ReDoS Prevention** ✅ FIXED
95
+ - **Issue**: Regular Expression Denial of Service (ReDoS) vulnerability in IPv6 validation
96
+ - **Solution**: Replaced complex regex with multi-step validation approach
97
+ - **Impact**: Prevents catastrophic backtracking attacks while maintaining IPv6 support
98
+ - **Location**: `src/validators/string.ts`, `src/coercion/string.ts`
99
+
100
+ #### **BUG-005: Safe String Coercion** ✅ FIXED
101
+ - **Issue**: Unsafe type coercion without length limits or sanitization
102
+ - **Solution**: Added length limits (1M characters) and control character sanitization
103
+ - **Impact**: Prevents DoS attacks and information disclosure through malicious strings
104
+ - **Location**: `src/coercion/string.ts`
105
+
106
+ ### 📊 Quality Improvements
107
+ - **Test Coverage**: Maintained excellent coverage at **96.55%** with **695 passing tests**
108
+ - **Performance**: All security improvements maintain VLD's performance advantages
109
+ - **Backwards Compatibility**: All changes are fully backwards compatible
110
+ - **Security Testing**: Comprehensive security test suite added with 18 dedicated tests
111
+
112
+ ### 🧪 Testing & Validation
113
+ - **Security Test Suite**: Added comprehensive security validation tests
114
+ - **Performance Tests**: Verified security fixes don't impact performance
115
+ - **Integration Tests**: Validated compatibility with existing codebases
116
+ - **Memory Tests**: Confirmed no memory leaks with security enhancements
117
+
118
+ ### 📝 Documentation Updates
119
+ - **Security Documentation**: Detailed security analysis reports created
120
+ - **Bug Fix Reports**: Comprehensive documentation of all fixes implemented
121
+ - **Test Coverage**: Updated coverage metrics to reflect new security tests
122
+ - **README**: Updated to reflect latest test coverage and security improvements
123
+
124
+ ### 🔧 Technical Details
125
+ - **Zero Breaking Changes**: All security improvements are backwards compatible
126
+ - **Immutable Architecture**: Security hardening maintains VLD's immutable validator pattern
127
+ - **Type Safety**: Enhanced type checking without compromising TypeScript inference
128
+ - **Error Handling**: Improved error messages for security-related validation failures
129
+
130
+ ## [1.2.0] - 2025-08-24
131
+
132
+ ### 🎯 **100% Test Success Rate Achieved**
133
+ - **569 tests passing** with 0 failures across all test suites
134
+ - **97.3% statement coverage** (up from 97.18%)
135
+ - **93.5% branch coverage**
136
+ - **96.78% function coverage**
137
+ - **97.6% line coverage**
138
+ - All Zod-compatible codec tests now fully passing
139
+
140
+ ### 🚀 Major Features Added
141
+
142
+ #### **Codec System - Bidirectional Transformations**
143
+ - **NEW**: Complete codec system for bidirectional data transformations
144
+ - `v.codec()` factory method for creating custom codecs
145
+ - Full encode/decode support with type safety
146
+ - Async codec support with `parseAsync()` and `encodeAsync()` methods
147
+ - Comprehensive error handling for both directions
148
+
149
+ #### **19 Built-in Zod-Compatible Codecs**
150
+
151
+ **String Conversion Codecs:**
152
+ - `stringToNumber` - String ↔ Number with validation
153
+ - `stringToInt` - String ↔ Integer with validation
154
+ - `stringToBigInt` - String ↔ BigInt conversion
155
+ - `numberToBigInt` - Number ↔ BigInt conversion
156
+ - `stringToBoolean` - Flexible string ↔ boolean (`'true'`, `'1'`, `'yes'`, `'on'` → `true`)
157
+
158
+ **Date Conversion Codecs:**
159
+ - `isoDatetimeToDate` - ISO 8601 string ↔ Date object
160
+ - `epochSecondsToDate` - Unix seconds ↔ Date object
161
+ - `epochMillisToDate` - Unix milliseconds ↔ Date object
162
+
163
+ **JSON and Complex Data:**
164
+ - `jsonCodec()` - Generic JSON string ↔ any type
165
+ - `base64Json()` - Base64-encoded JSON with schema validation
166
+ - `jwtPayload()` - JWT payload decoder (read-only)
167
+
168
+ **URL and Web:**
169
+ - `stringToURL` - String ↔ URL object
170
+ - `stringToHttpURL` - HTTP/HTTPS URL validation and conversion
171
+ - `uriComponent` - URI component encode/decode
172
+
173
+ **Binary Data:**
174
+ - `base64ToBytes` - Base64 ↔ Uint8Array
175
+ - `base64urlToBytes` - URL-safe Base64 ↔ Uint8Array
176
+ - `hexToBytes` - Hexadecimal ↔ Uint8Array
177
+ - `utf8ToBytes` - UTF-8 string ↔ Uint8Array
178
+ - `bytesToUtf8` - Uint8Array ↔ UTF-8 string
179
+
180
+ #### **New Validator Types**
181
+ - `v.base64()` - Base64 string validation with URL-safe mode
182
+ - `v.hex()` - Hexadecimal string validation with lowercase mode
183
+ - `v.uint8Array()` - Uint8Array validation with length constraints
184
+
185
+ #### **Enhanced Utilities**
186
+ - Comprehensive codec utility functions in `codec-utils.ts`
187
+ - Cross-platform Base64 encoding/decoding (Node.js + Browser)
188
+ - Secure error handling for all codec operations
189
+
190
+ ### 📚 Documentation Updates
191
+ - **README.md**: Comprehensive codec documentation with examples
192
+ - **API.md**: Complete codec API reference with TypeScript examples
193
+ - **New Examples**:
194
+ - `examples/codecs.js` - JavaScript codec examples
195
+ - `examples/codecs.ts` - TypeScript codec examples with full type safety
196
+ - Updated CLAUDE.md with codec development guidance
197
+
198
+ ### 🔧 Technical Improvements
199
+ - **Zero Circular Dependencies**: Refactored codec architecture
200
+ - **Full Type Safety**: Complete TypeScript support with inference
201
+ - **97.3% Test Coverage**: Comprehensive test suite with 569 passing tests
202
+ - **Error Message Localization**: All codec errors support 27+ languages
203
+
204
+ ### 🎯 Zod Compatibility
205
+ - **100% Zod Codec Parity**: All Zod codecs implemented and compatible
206
+ - **Beyond Zod**: Additional codecs not available in Zod
207
+ - **Drop-in Replacement**: Seamless migration path from Zod codecs
208
+
209
+ ### Performance
210
+ - **Optimized Transformations**: Efficient bidirectional conversions
211
+ - **Memory Efficient**: Immutable codec architecture prevents leaks
212
+ - **Async Support**: Non-blocking operations for I/O-bound transformations
213
+
214
+ ## [1.1.1] - 2025-08-18
215
+
216
+ ### Security
217
+ - **CRITICAL**: Fixed prototype pollution vulnerability in VldObject passthrough mode
218
+ - Added protection against `__proto__`, `constructor`, and `prototype` key pollution
219
+ - Comprehensive security test suite added
220
+
221
+ ### Fixed
222
+ - Removed unnecessary escape characters in regex patterns (URL validation)
223
+ - Fixed escape characters in locale files (Afrikaans)
224
+ - Added ESLint configuration for code quality
225
+
226
+ ### Added
227
+ - Security test suite with prototype pollution prevention tests
228
+ - Coverage improvement tests for better code quality
229
+ - ESLint configuration with TypeScript support
230
+
231
+ ### Changed
232
+ - Improved test coverage to 97.1% statements
233
+ - All linting issues resolved
234
+
235
+ ## [1.1.0] - 2025-08-12
236
+
237
+ ### Added
238
+ - Professional benchmark suite with real-world performance testing
239
+ - `benchmarks/quick-bench.cjs` - Fast performance comparison
240
+ - `benchmarks/memory.cjs` - Memory usage analysis
241
+ - `benchmarks/startup.cjs` - Startup time comparison
242
+ - `benchmarks/performance.cjs` - Comprehensive benchmark suite
243
+ - Complete documentation overhaul in `/docs` folder:
244
+ - `API.md` - Full API reference with all methods and examples
245
+ - `GETTING_STARTED.md` - Beginner-friendly guide
246
+ - `MIGRATION.md` - Step-by-step Zod to VLD migration
247
+ - `PERFORMANCE.md` - Performance optimization guide
248
+ - `ADVANCED_FEATURES.md` - Deep dive into advanced features
249
+
250
+ ### Changed
251
+ - Updated README with accurate benchmark results showing 2.07x average improvement
252
+ - All documentation converted to English
253
+ - Improved build process with automatic ES module import fixes
254
+ - Test coverage increased to 99.5%
255
+ - Cleaned up project structure for better maintainability
256
+
257
+ ### Removed
258
+ - Deleted `coverage/` folder (unnecessary for npm package)
259
+ - Removed 12 old benchmark files
260
+ - Cleaned up `src/errors/` and `src/types/` folders
261
+ - Removed redundant test files focused on coverage metrics
262
+ - Deleted unnecessary example files
263
+
264
+ ### Fixed
265
+ - Fixed ES module import issues with `.js` extension resolver
266
+ - Resolved CommonJS compatibility for benchmark files
267
+ - Fixed all TypeScript compilation errors
268
+ - Corrected package.json export configurations
269
+
270
+ ### Performance
271
+ - Memory usage: 86% less than Zod
272
+ - Startup time: 1.94x faster
273
+ - Schema creation: 8.22x faster
274
+ - Overall performance: 2.07x faster average
275
+
276
+ ## [1.0.0] - 2025-08-11
277
+
278
+ ### Initial Release
279
+
280
+ #### Core Features
281
+ - **Blazing Fast Performance**: 2-4x faster than Zod in most operations
282
+ - **Zero Dependencies**: Lightweight with no external packages
283
+ - **Full TypeScript Support**: Excellent type inference and IntelliSense
284
+ - **Zod API Compatibility**: Drop-in replacement with identical API
285
+ - **Tree-Shakeable**: Only import what you need
286
+
287
+ #### Validation Types
288
+ - **Primitives**: string, number, boolean, bigint, symbol, date, undefined, null, void, any, unknown, never
289
+ - **Collections**: array, tuple, object, record, map, set
290
+ - **Compositions**: union, intersection, literal, enum
291
+ - **Modifiers**: optional, nullable, nullish, default, catch
292
+
293
+ #### Advanced Features
294
+ - **Type Coercion**: Automatic type conversion for common cases
295
+ - **Custom Validation**: `refine()` and `superRefine()` for custom logic
296
+ - **Data Transformation**: `transform()` for post-validation processing
297
+ - **Object Utilities**: `pick()`, `omit()`, `extend()`, `merge()`, `partial()`
298
+ - **Error Formatting**: Tree, pretty, and flatten utilities
299
+
300
+ #### Internationalization
301
+ - Built-in support for 27+ languages
302
+ - Easy locale switching with `setLocale()`
303
+ - Comprehensive translation coverage
304
+
305
+ #### String Validators
306
+ - Email, URL, UUID validation
307
+ - IP address (v4/v6) validation
308
+ - Regex pattern matching
309
+ - Length constraints (min, max, length)
310
+ - Content checks (includes, startsWith, endsWith)
311
+ - Transformations (trim, toLowerCase, toUpperCase)
312
+
313
+ #### Number Validators
314
+ - Range validation (min, max)
315
+ - Type constraints (int, positive, negative, finite, safe)
316
+ - Mathematical checks (multipleOf)
317
+
318
+ #### Performance Optimizations
319
+ - Optimized for V8 JavaScript engine
320
+ - Minimal memory allocations
321
+ - Fast-path optimizations for common cases
322
+ - Immutable validators prevent memory leaks
323
+ - Pre-computed validation strategies
324
+
325
+ #### Developer Experience
326
+ - Clear, actionable error messages
327
+ - Comprehensive test suite (99.5% coverage)
328
+ - Extensive documentation and examples
329
+ - TypeScript-first design
330
+ - Intuitive, chainable API
331
+
332
+ ---
333
+
334
334
  For more details, see the [GitHub Releases](https://github.com/ersinkoc/vld/releases)