Releases: ReactMVC/API-Monster
Releases · ReactMVC/API-Monster
1.9.0
1.8.0
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
Add Data Validation
<?php
namespace Monster\App\Controllers;
use Monster\App\Models\Validation;
class HomeController
{
public function index()
{
$data = [
'name' => 'John Doe',
'email' => 'john.doe@example.com',
'age' => 19
];
$rules = [
'name' => 'required',
'email' => 'required|email',
'age' => 'number|min:1|max:3'
];
$validator = new Validation($data, $rules, 'en');
if ($validator->validate()) {
echo 'Data is valid!';
} else {
$errors = $validator->getErrors();
print_r($errors);
}
}
}