Skip to content

Commit b77c62a

Browse files
committed
refactor(core): migrate runtime classes to Validator namespace
This commit refactors the project structure by moving all runtime classes from the `Lemmon` namespace to the `Lemmon\Validator` namespace. The following changes are included: - All classes in `src/Lemmon` have been moved to `src/Lemmon/Validator`. - The namespace in all affected classes has been updated to `Lemmon\Validator`. - All documentation and examples have been updated to reflect the new namespace. - All tests have been updated to use the new namespace. - The `AGENTS.md` and `CHANGELOG.md` files have been updated to document the change. This change improves the project structure and aligns with the architecture described in `AGENTS.md`.
1 parent bb80ea3 commit b77c62a

36 files changed

Lines changed: 122 additions & 108 deletions

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ A comprehensive, fluent validation library for PHP inspired by Valibot and Zod.
44

55
## Architecture
66

7+
- **Root Namespace** - Runtime classes live under `Lemmon\Validator`; tests use `Lemmon\Tests`
8+
79
### Core Factory Pattern
810
- **`Validator`** - Static factory creating type-specific validators (`isString()`, `isInt()`, `isFloat()`, `isArray()`, `isAssociative()`, `isObject()`, `isBool()`)
911
- **`FieldValidator`** - Abstract base class with unified validation interface and shared functionality

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
6+
### Changed
7+
- Migrated all runtime classes to the `Lemmon\Validator` namespace and aligned documentation/examples with the new structure.
68

79
## [0.7.0] - 2025-10-19
810

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ Rather than reimplementing every possible transformation or validation rule, Lem
4949

5050
## Quick Start
5151

52+
All runtime classes live under the `Lemmon\Validator` namespace.
53+
5254
```php
53-
use Lemmon\Validator;
55+
use Lemmon\Validator\Validator;
5456

5557
// Simple validation with form-safe coercion
5658
$email = Validator::isString()

docs/examples/form-validation.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ This guide demonstrates how to use the Lemmon Validator for common form validati
3636

3737
```php
3838
<?php
39-
use Lemmon\Validator;
40-
use Lemmon\ValidationException;
39+
use Lemmon\Validator\Validator;
40+
use Lemmon\Validator\ValidationException;
4141

4242
class ContactFormValidator
4343
{
@@ -272,11 +272,11 @@ if (!$result['valid']) {
272272

273273
```php
274274
<?php
275-
use Lemmon\Validator;
275+
use Lemmon\Validator\Validator;
276276

277277
class UserRegistrationValidator
278278
{
279-
public function createValidator(): \Lemmon\AssociativeValidator
279+
public function createValidator(): \Lemmon\Validator\AssociativeValidator
280280
{
281281
return Validator::isAssociative([
282282
// Personal Information
@@ -366,7 +366,7 @@ class UserRegistrationValidator
366366
]);
367367
}
368368

369-
private function createPasswordValidator(): \Lemmon\StringValidator
369+
private function createPasswordValidator(): \Lemmon\Validator\StringValidator
370370
{
371371
return Validator::isString()
372372
->required('Password is required')
@@ -483,11 +483,11 @@ class RegistrationController
483483

484484
```php
485485
<?php
486-
use Lemmon\Validator;
486+
use Lemmon\Validator\Validator;
487487

488488
class ProductFormValidator
489489
{
490-
public function createValidator(): \Lemmon\AssociativeValidator
490+
public function createValidator(): \Lemmon\Validator\AssociativeValidator
491491
{
492492
return Validator::isAssociative([
493493
// Basic Information
@@ -668,7 +668,7 @@ class ProductFormValidator
668668

669669
```php
670670
<?php
671-
use Lemmon\Validator;
671+
use Lemmon\Validator\Validator;
672672

673673
class MultiStepRegistrationValidator
674674
{

docs/getting-started/basic-usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This guide covers the fundamental concepts and usage patterns of the Lemmon Vali
77
All validation starts with the `Validator` factory class, which provides static methods to create specific validator instances:
88

99
```php
10-
use Lemmon\Validator;
10+
use Lemmon\Validator\Validator;
1111

1212
// Create validators for different types
1313
$stringValidator = Validator::isString();

docs/getting-started/core-concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Validation Rules (email(), min(), etc.)
2121
The `Validator` class is a factory that creates specific validator instances:
2222

2323
```php
24-
use Lemmon\Validator;
24+
use Lemmon\Validator\Validator;
2525

2626
// Factory methods create specific validators
2727
$string = Validator::isString(); // → StringValidator

docs/getting-started/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The package follows PSR-4 autoloading standards. If you're using Composer's auto
2121
<?php
2222
require_once 'vendor/autoload.php';
2323

24-
use Lemmon\Validator;
24+
use Lemmon\Validator\Validator;
2525

2626
// Ready to use!
2727
$validator = Validator::isString();
@@ -35,7 +35,7 @@ Verify your installation by running a simple validation:
3535
<?php
3636
require_once 'vendor/autoload.php';
3737

38-
use Lemmon\Validator;
38+
use Lemmon\Validator\Validator;
3939

4040
try {
4141
$result = Validator::isString()->email()->validate('test@example.com');

docs/guides/array-validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This guide covers array validation using the `ArrayValidator` class, which handl
1515
### Simple Array Validation
1616

1717
```php
18-
use Lemmon\Validator;
18+
use Lemmon\Validator\Validator;
1919

2020
// Validate indexed arrays
2121
$validator = Validator::isArray();
@@ -293,7 +293,7 @@ $result = $nestedArray->validate([
293293
### Basic Error Handling
294294

295295
```php
296-
use Lemmon\ValidationException;
296+
use Lemmon\Validator\ValidationException;
297297

298298
$validator = Validator::isArray();
299299

docs/guides/custom-validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The Lemmon Validator allows you to add custom validation logic using the `satisf
77
### Simple Custom Rule
88

99
```php
10-
use Lemmon\Validator;
10+
use Lemmon\Validator\Validator;
1111

1212
$validator = Validator::isString()->satisfies(
1313
function ($value) {

docs/guides/error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The library provides two validation approaches with different error handling str
1111
Throws a `ValidationException` when validation fails:
1212

1313
```php
14-
use Lemmon\Validator;
15-
use Lemmon\ValidationException;
14+
use Lemmon\Validator\Validator;
15+
use Lemmon\Validator\ValidationException;
1616

1717
$validator = Validator::isString()->email();
1818

0 commit comments

Comments
 (0)