Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[2.0.0] - 2024-01-XXโ
๐ Major Changesโ
Complete Architecture Rewriteโ
- BREAKING: Complete rewrite of the validation engine for better performance and maintainability
- BREAKING: New modular architecture with separate builders for each data type
- BREAKING: Updated import paths and API structure
Enhanced Export Structureโ
- NEW: Added top-level convenience functions (
configure
,extend
,usePreset
,createPreset
) - NEW: Direct
GlobalConfig
export for advanced configuration access - IMPROVED: Maintained backward compatibility with
Validator
static methods - IMPROVED: Multiple API styles - choose between top-level functions or class-based methods
โจ New Featuresโ
Improved Developer Experienceโ
// Multiple ways to configure - choose your preferred style:
// Option 1: Top-level functions (Recommended)
import { configure, extend, usePreset } from 'validlyjs';
configure({ language: 'en' });
extend('custom_rule', { validate: ..., message: ... });
usePreset('laravel');
// Option 2: Validator static methods
import { Validator } from 'validlyjs';
Validator.configure({ language: 'en' });
Validator.extend('custom_rule', { validate: ..., message: ... });
// Option 3: Direct GlobalConfig access (Advanced)
import { GlobalConfig } from 'validlyjs';
GlobalConfig.configure({ language: 'en' });
Enhanced Type Systemโ
- Added comprehensive TypeScript interfaces for all validation types
- New
RuleDefinition
,ValidatorOptions
, andValidationError
types - Better type inference for fluent API methods
Union Validationโ
- NEW:
union()
builder for validating values against multiple rule sets - Support for "either/or" validation scenarios
- Configurable stop-on-first-pass behavior
Advanced Framework Integrationโ
React Integrationโ
- New
useValidation
hook with reactive validation - Support for form validation with real-time feedback
- Integration with React form libraries
Vue Integrationโ
- New
useValidation
composable for Vue 3 - Vue directives:
v-validate
,v-validate-on
,v-error-display
- Reactive validation with Vue's reactivity system
Node.js Integrationโ
- NEW: CJS and ESM support for Node
- NEW: Express.js middleware with
ExpressValidator
- NEW: Fastify plugin with
FastifyValidator
- Support for validating request body, query, params, and headers
- Configurable error handling and response formats
Enhanced Configuration Systemโ
- NEW:
GlobalConfig
class for centralized configuration - NEW: Top-level configuration functions for better DX
- Support for configuration presets (Laravel, API, Form)
- Environment-specific configurations
- Advanced validation options with hooks and custom type coercion
Flexible Custom Rules Systemโ
- NEW: Multiple ways to register custom rules:
- Global rules:
extend('ruleName', definition)
orValidator.extend()
- Instance rules:
validator.extend('ruleName', definition)
- Global rules:
- NEW: Enhanced
CustomRuleDefinition
interface - NEW: Better parameter handling and async support
Performance Improvementsโ
- EXPERIMENTAL: Performance monitoring and optimization features
- Caching system for compiled rules
- Optimized validation algorithms
- Memory leak prevention
Advanced Validation Featuresโ
- NEW: Conditional validation with
when()
method. This is still experimental. - Enhanced file validation with dimension checking
- Network validation rules (IP, URL, etc.)
- Better async validation support
๐ง Improvementsโ
Enhanced Fluent APIโ
- More intuitive method chaining
- Better parameter validation
- Improved error messages
Better Error Handlingโ
- Multiple error response formats (Laravel, flat, grouped, nested)
- Customizable error messages per field
- Multi-language support with language packs
Development Experienceโ
- Better TypeScript support with strict typing
- Comprehensive test suite with integration tests
- Performance benchmarking tools
- Memory leak detection
๐ Migration Guideโ
From v1.x to v2.0โ
Configuration (Multiple Options)โ
// v1.x
import { configure } from 'validlyjs';
configure({ language: 'en' });
// v2.0 - Option 1: Top-level function (Recommended)
import { configure } from 'validlyjs';
configure({ language: 'en' });
// v2.0 - Option 2: Validator static method
import { Validator } from 'validlyjs';
Validator.configure({ language: 'en' });
// v2.0 - Option 3: Direct GlobalConfig (Advanced)
import { GlobalConfig } from 'validlyjs';
GlobalConfig.configure({ language: 'en' });
Custom Rules (Multiple Options)โ
// v1.x
import { extend } from 'validlyjs';
extend('custom_rule', validator, message);
// v2.0 - Option 1: Top-level function (Recommended)
import { extend } from 'validlyjs';
extend('custom_rule', {
validate: (value, params) => { /* validation logic */ },
message: 'Custom validation message'
});
// v2.0 - Option 2: Validator static method
import { Validator } from 'validlyjs';
Validator.extend('custom_rule', {
validate: (value, params) => { /* validation logic */ },
message: 'Custom validation message'
});
// v2.0 - Option 3: Instance method (for specific validators)
const validator = new Validator({}, {});
validator.extend('custom_rule', {
validate: (value, params) => { /* validation logic */ },
message: 'Custom validation message'
});
Basic Validationโ
// v1.x
import { Validator } from 'validlyjs';
const validator = new Validator(data, {
email: 'required|email',
age: 'required|numeric|min:18'
});
// v2.0
import { Validator, string, number } from 'validlyjs';
const validator = new Validator(data, {
email: string().required().email(),
age: number().required().min(18)
});
Framework Integrationโ
// v1.x
import { useValidator } from 'validlyjs';
// v2.0 - React
import { useValidation } from 'validlyjs/react';
// v2.0 - Vue
import { useValidation } from 'validlyjs/vue';
๐ฆ Dependenciesโ
Updatedโ
- Upgraded to support Node.js 16+
- Better tree-shaking support
- Reduced bundle size through modular architecture