Respect / Validation

The most awesome validation engine ever created for PHP
https://respect-validation.readthedocs.io
MIT License
5.75k stars 774 forks source link

Roadmap to 3.0 #1447

Open henriquemoody opened 5 months ago

henriquemoody commented 5 months ago

NOTE: I will be away until mid-April. Things are very busy at work at the moment, so I will have to pause working in this release for a little while.


To-dos

Rules

Core

Other

Here are some "problems" I see with the current engine

On version 3.0, this won't be possible anymore:

$email = new Email():
$email->assert($input);

Instead, you would need to do that:

$validator = new Validator(new Email());
$validator->assert($input);

However, because assert() and check() will be available only on Validator, you could do things like that:

// Passing the template as a string
v::email()->check($input, 'Uff... {{input}} should have been an email');

// Passing an array of templates
v::intValue()->positive()->lessThan(5)->assert($input, [
    'intValue' => 'Area must be an integer',
    'positive' => 'Area must be a positive number',
    'lessThan' => 'Area cannot be bigger than m2',
]);

// Passing a custom exception
v::email()->check($input, new DomainException('Customers must have valid emails'));
v::email()->assert($input, new DomainException('Customers must have valid emails'));