You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: introduce satisfies* API and complete internal modernization
BREAKING CHANGES:
- oneOf() method removed from ArrayValidator and ObjectValidator (now available only on primitive validators via OneOfTrait)
Added:
- New satisfies* API for enhanced logical combinators:
- satisfiesAny(array , ?string = null)
- satisfiesAll(array , ?string = null)
- satisfiesNone(array , ?string = null)
- Enhanced satisfies() method now accepts callable|FieldValidator instances
- OneOfTrait for type-safe oneOf() implementation on primitive validators
- Optional error message parameter for required() method
Changed:
- Deprecated instance methods anyOf(), allOf(), not() (maintained as aliases)
- Complete internal migration from addValidation() to satisfies():
- StringValidator: 10 methods migrated
- NumericConstraintsTrait: 5 methods migrated
- Static combinators: Validator::anyOf(), allOf(), not() use new satisfies* API
- oneOf() now implemented as transformation, respecting execution order
- Updated test suite to use new satisfies* API (135 tests, 390 assertions)
Documentation:
- Updated all documentation to reflect new API
- Added comprehensive satisfies* API documentation
- Updated examples and guides
- Added deprecation notices for backward compatibility
This achieves complete internal API consistency while maintaining perfect backward compatibility.
-**Comprehensive Error Collection** - All validation errors collected, not just the first failure
33
33
-**Smart Type Coercion** - Configurable automatic type conversion with form-friendly defaults
34
-
-**Fluent API** - Chainable method calls for readable validation code
34
+
-**Fluent API with guaranteed execution order** - Chainable method calls that execute in the exact order written
35
35
36
36
### Developer Experience
37
37
-**Dual Validation Methods** - `validate()` (exception-based) and `tryValidate()` (tuple-based)
@@ -65,7 +65,7 @@ A comprehensive, fluent validation library for PHP inspired by Valibot and Zod.
65
65
## 🔧 Development Workflow
66
66
67
67
### Code Quality
68
-
-**Testing** - Pest PHP with organized test suite (10 focused test files, 131 tests, 375 assertions)
68
+
-**Testing** - Pest PHP with organized test suite (10 focused test files, 135 tests, 390 assertions)
69
69
-**Static Analysis** - PHPStan at maximum level for type safety
70
70
-**Code Style** - PHP-CS-Fixer for consistent formatting
71
71
-**Performance** - Optimized validation logic with eliminated code duplication
@@ -108,9 +108,9 @@ tests/
108
108
109
109
### Key Metrics
110
110
-**8 validator types** covering all PHP data types
111
-
-**35+ built-in validation methods** including static logical combinators, array filtering, type-aware transformations, form-safe coercion, and intuitive custom validation
111
+
-**35+ built-in validation methods** including static logical combinators, array filtering, type-aware transformations, form-safe coercion, and intuitive custom validation (all using modern `satisfies()` API internally)
112
112
-**5,000+ lines of documentation** with practical examples and comprehensive coverage
113
-
-**131 unit tests** with comprehensive coverage (375 assertions)
113
+
-**135 unit tests** with comprehensive coverage (390 assertions)
114
114
-**Zero technical debt** with modern PHP 8.1+ codebase
115
115
-**Zero dead links** in documentation with seamless navigation
116
116
-**Complete API documentation** with accurate method signatures and examples
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,15 +26,15 @@ Rather than reimplementing every possible transformation or validation rule, Lem
26
26
**Key Design Principles:**
27
27
28
28
-**Form Safety First**: Empty strings coerce to `null` (not dangerous `0`/`false`) to prevent real-world issues like accidental zero bank balances
29
-
-**Fluent API**: Validation rules read like natural language and execute in the order written - `Validator::isString()->pipe('trim')->nullifyEmpty()->required()`
29
+
-**Fluent API with Execution Order Guarantee**: Validation rules read like natural language and execute in the exact order written - `Validator::isString()->pipe('trim')->nullifyEmpty()->required()`
30
30
-**Comprehensive Error Collection**: All validation errors are collected, not just the first failure
31
31
-**Type-Aware Transformations**: Intelligent transformation system that maintains type context and handles coercion automatically
32
32
-**Extensible Architecture**: Generic transformation methods work with any PHP callable or external library
33
33
34
34
## Features
35
35
36
36
-**Type-safe validation** for strings, integers, floats, arrays, and objects
37
-
-**Fluent, chainable API** for readable and maintainable validation rules
37
+
-**Fluent, chainable API**with guaranteed execution order for readable and maintainable validation rules
38
38
-**Comprehensive error collection** with detailed, structured feedback
39
39
-**Intuitive custom validation** with `satisfies()` method and optional error messages
40
40
-**Logical combinators** (`Validator::allOf()`, `Validator::anyOf()`, `Validator::not()`) for complex validation logic
**Available on:**`StringValidator`, `IntValidator`, `FloatValidator`, `BoolValidator` only
637
+
638
+
Restricts the value to one of the specified allowed values. This method is implemented as a transformation and respects the fluent API execution order.
0 commit comments