Commit graph

2012 commits

Author SHA1 Message Date
Henrique Moody fb28332417
Remove version alias for "dev-master"
I don't know whether the next version will be a MINOR or a MAJOR
version, therefore it makes no sense to keep an alias for "dev-master".

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 23:29:52 +02:00
Henrique Moody 96116e0ff6
Remove current disclaimer about current stable version
As I'm about to release version 2.0, that disclaimer won't be necessary
anymore.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 23:28:32 +02:00
Henrique Moody f4593b7479
Drop support for PHP < 7.3
I am about to release version 2.0, and it's been way too much time since
I created a MINOR or MAJOR version.

Because I don't know when will be the next time I will release the next
version and it is troublesome to keep support to old PHP versions, I
decided to only give support to the versions PHP is actively supporting.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 23:23:23 +02:00
Henrique Moody b9e73db494
Add support for PHP 7.4 version
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 22:29:03 +02:00
Henrique Moody 9a868f6e5f
Update "egulias/email-validator" version
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 22:12:06 +02:00
Henrique Moody 2a8b0770d6
Update "malukenho/docheader" version
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 22:11:04 +02:00
Henrique Moody 2fb08236c5
Update PHP_CodeSniffer version
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 22:10:00 +02:00
Henrique Moody 42300ef48e
Update PHPUnit version
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 21:06:23 +02:00
Henrique Moody 9a41f64479
Fix possible error when recursing exceptions
The method "current()" from NestedValidationException can return any
instance of ValidationException, but the implementation of
"getChildren()" requires it to return an instance of
"NestedValidationException".

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 21:01:30 +02:00
Henrique Moody ec8874808f
Move "MaxAgeTest" to the correct directory
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-06-04 20:50:01 +02:00
Henrique Moody 2d0f56d9cb
Merge branch '1.1'
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>
2019-05-29 23:17:53 +02:00
Henrique Moody 45d109fc83
Update list of currency codes
This commit will also create a Bash script to update that list in the
future.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-28 08:10:06 +02:00
Henrique Moody c51931679c
Update list of language code
This commit will also create a Bash script to update that list in the
future.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-28 08:02:57 +02:00
Henrique Moody 8b8f7db713
Update list of subdivision codes
To update the list of subdivisions, 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>
2019-05-26 16:18:49 +02:00
Henrique Moody f580e187d0
Update list of Country Codes
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>
2019-05-26 14:59:41 +02:00
Henrique Moody 9b810b0e55
Create script to update TLD list
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-26 13:18:47 +02:00
Henrique Moody 5c61c25680
Update TLD list to version 2019052600
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-26 13:12:16 +02:00
Henrique Moody 14e8eee7a0
Create script to update documentation links
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-23 23:16:04 +02:00
Henrique Moody 5858d06097
Update contribution guidelines
Some links do not work and the documentation is outdated.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-23 16:35:41 +02:00
Henrique Moody 1dace92e89
Simplify "README.md" file
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-23 16:27:51 +02:00
Henrique Moody ef8a8f4b27
Turn LICENSE file into plain/text
There is no need for that file to be a Markdown, and it can be a plain
text file.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-23 16:21:34 +02:00
Henrique Moody 1b0be4c3a6
Remove documentation links in the repository
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-23 16:16:00 +02:00
Henrique Moody 32d796ed3d
Add warning about the stable version
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-22 21:16:57 +02:00
Henrique Moody 6a52b63bbb
Remove duplication amoung documentations
There is quite some duplication between the "README.md" file and the
"docs/index.md". This commit will separate what belongs to the
documentation and what is specific of the repository.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-22 21:07:26 +02:00
Henrique Moody b88da74f79
Update number of rules in the documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-22 21:01:13 +02:00
Henrique Moody 1b146758ee
Upgrade supported PHP version in the documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-22 20:59:22 +02:00
Henrique Moody 408d8e825b
Move "Message placeholder conversion" documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-22 20:56:22 +02:00
Henrique Moody 5c0bd3a5da
Move "Message translation" documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-22 20:56:09 +02:00
Henrique Moody 7be7f0f58c
Move "Custom rules" documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-22 20:55:59 +02:00
Danilo Correa fbf82dc975
Replace removed rule from documentation
The "Age" was removed but the documentation was not completely updated.
2019-05-22 20:37:28 +02:00
Henrique Moody 3093d79155
Allow to customize parameter stringifier
We have seen users that want to change the default behavior of parameter
stringifier:

* Change the depth level shown from an array.

* Change the number of elements shown from an array.

* Not add quotes to some parameters.

Because of that, this commit will allow users to customize the parameter
stringifier.

This commit will also update the documentation to instruct how to
customize it.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-12 13:49:54 +02:00
Henrique Moody 00f61b9bdc
Move message formatting out of ValidationException
There should not be too much code in the ValidationException. It is hard
to test and debug code in exceptions because PHP does not trace further
than their constructor.

This commit will move the message formatting from ValidationException
into a Formatter class (inside a Message namespace).

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-12 13:45:38 +02:00
Henrique Moody ab602ae1bb
Improve how to customize the Factory
The constructor of "Factory" has three arguments and, even though none
of them are needed, they are all required. Those arguments allow users
to customize the namespaces of rules and exceptions, and also to define
a callable that will translate the template messages.

This commit will remove those parameters from the constructor of
"Factory," and create methods that will allow users to customize the
namespaces and the translator.

The methods that this commit will create will not change the state of
"Factory," but they will create a clone with the customizations. It is
imperative that the "Factory" is immutable. Since the "Factory" is a
Singleton, allowing it to change could cause unexpected behaviors.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-12 12:24:44 +02:00
Henrique Moody f3bc39066b
Make default templates non-static and protected
The only reason why those templates are static is so users can overwrite
the exception messages. That was useful when we didn't have a handy
translator, but now that we can define a translator through the Factory,
this is not needed anymore.

Besides, having those properties public adds complexity to the code.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-12 09:57:07 +02:00
Henrique Moody c522f6235c
Remove "IdentityCard" in favor of "PolishIdCard"
The only Identity Card we have is the Polish one, that said it makes
more sense to have a specific rule that only validates that, rather than
having a "IdentityCard" rule that only accepts one value.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-12 00:22:45 +02:00
Henrique Moody f23b3a522a
Remove "Vatin" in favor of "Nip"
There are not other VATINs besides the one from Poland. That said, it
makes more sense to have a specific rule that only validates NIP.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 23:44:10 +02:00
Henrique Moody 0417fea213
Fix confusion with some changelogs
The changelogs that this commit will change are confusing. From a code
perspective, the rule Date was renamed to DateTime, and OneOf was
renamed to AnyOf, but because we also created a Date and OneOf rule with
different behaviours, it makes more sense to say that their behaviour
changed, rather than saying that they were created in version 2.0.0.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 21:44:44 +02:00
Henrique Moody 16376306f8
Use "Respect" coding standard
There are too many PHP_CodeSniffer configurations in this repository.

I have created "respect/coding-standard" to deal with all the
configuration so in this repository we only need to add "Respect" as our
PHP_CodeSniffer rule.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 20:51:39 +02:00
Henrique Moody 272f18dcf5
Apply "Symfony.Functions.ScopeOrder"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 20:00:19 +02:00
Henrique Moody 9c0f8dcfcc
Rename rule "Cntrl" to "Control"
This commit will rename the rule by removing the abbreviation to make it
a bit easier to understand what it does and much easier to find.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 19:35:14 +02:00
Henrique Moody 4db2b00f6c
Update list of rules in "list-of-rules.md"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 19:16:33 +02:00
Henrique Moody 10df3211f5
Add "Categorization" section to rule documentations
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 19:16:21 +02:00
Henrique Moody b815fdff92
Move documentation about "Comparable Values"
This documentation is in the "rules" directory, but it should be outside
that directory since the "rules" directory is supposed to only have
documentation about rules.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 17:34:42 +02:00
Henrique Moody 6e4927a621
Fix broken links in "list-of-rules.md"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 17:30:04 +02:00
Henrique Moody 996b797db0
Add missing changelog entry in "Unique.md"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-11 17:28:35 +02:00
Henrique Moody 051866f75a
Make properties of "AbstractRelated" private
Following what is happening with pretty much every class in this
library, this commit will make the public properties of
"AbstractRelated" private.

Because other objects use some of those public properties, this commit
will also implement a couple of methods in "AbstractRelated" so they can
access the values they need.

This commit will also remove the method "decision" that makes dynamic
calls to "assert()," "check()," and "validate()" methods.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-05 16:54:04 +02:00
Henrique Moody 541fea9d7b
Fix syntax issue in ".travis.yml" file
On the step that was sending the code coverage to Scrutinizer, there is
an issue with the syntax after some changes in the Travis
configuration [1].

[1]: 5aba4c8889

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-05 16:52:56 +02:00
Henrique Moody 95b499b627
Apply "phpstan/phpstan-deprecation-rules" rules
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-05 15:18:09 +02:00
Henrique Moody d00ed89f3c
Apply "phpstan/phpstan-phpunit" rules
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-05 15:04:56 +02:00
Henrique Moody d58395626f
Remove exceptions from suvdivision code rules
The "SubdivisionCode" rule was refactored [1] and now it doesn't need
one rule per country.

This commit will also remove the exceptions that were supposed to be
removed before.

[1]: 718bacad04

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-05-05 14:55:11 +02:00