We want to release version 3.0 as fresh as possible, without having to
maintain backward compatibility with the previous versions. Because that
version will be on for some time, we decided it will be best to support
only PHP version 8.5 or higher.
Acked-by: Alexandre Gomes Gaigalas <alganet@gmail.com>
We want to release version 3.0 as fresh as possible, without having to
maintain backward compatibility with the previous versions.
Acked-by: Alexandre Gomes Gaigalas <alganet@gmail.com>
With this change, any rule can be used as a PHP attribute. I have wanted
to implement this feature for a while, as it allows you to bind the
validation to a specific property and just validate the object
afterwards.
I'm not a native English speaker, and the same goes for many
contributors from this library. Because of that, some messages just
don't sound very good, so I updated a lot of them.
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>
Since we now have PHP ISO Codes as a dependency[1], it doesn't make
sense to keep dealing with this data ourselves.
[1]: 04b2722d02
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
I don't find much use for those, and it's hard to be consistent with all
places that could throw an exception.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Creating a specific exception for each rule adds a painful overhead. If
you want to make a custom message for your rule, you will need to create
an exception and then register that exception namespace to be able to
use it—all that is just for customizing the message of your rule.
Having different namespaces also implies that you need to fetch the
exception of the rule from another directory to change it. As Uncle Bob
said, "Classes that change together belong together. Classes that are
not reused together should not be grouped."
This commit will drastically change this library, moving all the
templates from the exceptions to the rules. Consequently, the Factory
becomes much simpler, and the library gets a bit smaller, too.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
That will make it clear that we should not overwrite some properties.
Because of this change, I've made a few refactorings here and there.
It's nice to see that I've spotted some issues just because I was
setting some properties as `readonly`.
There are a few properties that I would like to make read-only, but to
do that I'd need to refactor a lot of code, so for now, I'm keeping it
as is.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This change will bring many breaking changes. The good thing is that we
can finally use more modern resources available in PHP.
I can imagine that's not a popular change since it will bring many
breaking changes to users, but we shouldn't be stuck in time because of
that. Using some of those features will make it easier to contribute to
the project. At least, I hope so.
There are still some useless doc-blocks, and we're not using "readonly"
properties when we could. I aim to send those changes soon.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Since we already have that library as a dependency of our repository, it
makes sense to use it as a source of country codes instead of keeping a
list of currencies ourselves.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit will revert the update of subdivision codes [1] since the
way we store this data is very different from the merged branch.
[1]: 8b8f7db713
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
To update the list of countries, I decided to use the iso-codes [1]
instead of GeoNames [2] as it seems like that one is more often updated.
This commit will also create a Bash script to update that list in the
future.
[1]: https://salsa.debian.org/iso-codes-team/iso-codes
[2]: http://www.geonames.org/
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
According to the official documentation [1] the correct way of writing
the "inheritDoc" tag is with the uppercase "D".
[1]: https://docs.phpdoc.org/guides/inheritance.html
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit will add a couple of rules that we already use but also
introduce new ones and make sure all the code is in accordance with the
new coding standards.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
The "AbstractSearcher" already does most of the job that "CountryCode"
was doing, so using it as parent class made more sense. That also makes
the validation case-sensitive which is not a problem since the standard
ISO 3166-1 in fact enforces an specific case for the country codes.
The documentation about the rule is also updated.
Co-Authored-By: Henrique Moody <henriquemoody@gmail.com>