fix: PSR-4 compliance — rename core/middleware/services to PascalCase for Linux server compatibility

This commit is contained in:
Hamza-Ayed
2026-05-05 16:24:47 +03:00
parent 50538bc5b9
commit fde1ee03d9
11 changed files with 452 additions and 0 deletions

25
app/Core/Validator.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
/**
* Simple Data Validator
*/
declare(strict_types=1);
namespace App\Core;
final class Validator
{
public static function validate(array $data, array $rules): array
{
$errors = [];
foreach ($rules as $field => $rule) {
if (str_contains($rule, 'required') && (empty($data[$field]) && $data[$field] !== '0')) {
$errors[$field] = "The {$field} field is required.";
}
if (str_contains($rule, 'email') && !empty($data[$field]) && !filter_var($data[$field], FILTER_VALIDATE_EMAIL)) {
$errors[$field] = "The {$field} must be a valid email address.";
}
}
return $errors;
}
}