Commit graph

4 commits

Author SHA1 Message Date
Henrique Moody 66faefd695
Remove previous validation engine
After many refactorings, no rules use the previous validation engine.
That means we can remove the unused code from the repository and switch
from the previous to the new validation engine everywhere.

This commit will also soft deprecate the methods "validate()", and
"check()" in all the rules and the "assert()" in all rules but the
Validator itself. That means using those methods will still be allowed,
but static analysis tools might complain.

This is a big step toward releasing the next major version, as the code
is pretty much the way it should be when I release the next version.
There's some documentation to be updated, and I would like to change the
behavior of a couple of rules.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-25 12:28:25 +01:00
Henrique Moody fe68eab37d
Allow to validate ArrayObject in key-related values
Because of that, I also updated some data providers to distinguish
between "values" and "types", similar to some of the rules we already
have.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-08 21:36:49 +01:00
Henrique Moody 81befe8fa1
Move core rules into the "Core" namespace
That helps organize the code better, making it easier to spot the core
rule. It also helps not allow the Factory to load those rules, as the
new namespace is not registered in it.

Note that the "AbstractAge", "AbstractRelated", and "AbstractRule" were
not moved. I want to do that only when I refactor them.

After I moved classes, I realized that "Comparison" and "FilteredString"
had no tests. I created the tests, and while I did that, I spotted two
bugs:

* The "Equals" rule was failing when comparing non-scalar wth scalar
  values;

* The "Equals" and "Identical" rules were not working correctly because
  "Comparison" was converting their values.

I fixed those bugs in this commit.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-03 16:12:58 +01:00
Henrique Moody 433ceb4452
Update the validation engine of the "Each" rule
These changes will also introduce an abstract rule that validates
non-empty-iterable values. The abstract rule can also be the parent of
the recently created "Min" rule. Therefore, I've changed that class too.

I've introduced many tests for the "Each" rule to make sure what its
expected behavior is. I'm not super happy with its output, but I tried a
couple of options, and it is the best choice.

Note that Each now rejects `stdClass` and empty iterable values. I
thought that would make sense, as it would be useless when the input is
empty.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-03 14:45:47 +01:00