Commit graph

111 commits

Author SHA1 Message Date
Henrique Moody 97b243daa1
Allow building rules using prefixes
Although helpful, the changes in the Min, Max, and Length rules made
using those rules more verbose. This commit will simplify their use by
allowing users to use them as prefixes.

Because I was creating prefixes for those rules, I made other cool
prefixes. Doing that is scary because it will generate more code to
support, and I would have liked to avoid that. However, that's a
valuable addition, and it's worth the risk.

I might reconsider that in the future, but for now, that looks like a
good idea.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-24 16:58:24 +01:00
dependabot[bot] 85bff04ad8
Update psr/http-message requirement from ^1.0 to ^1.0 || ^2.0
Updates the requirements on [psr/http-message](https://github.com/php-fig/http-message) to permit the latest version.
- [Release notes](https://github.com/php-fig/http-message/releases)
- [Changelog](https://github.com/php-fig/http-message/blob/master/CHANGELOG.md)
- [Commits](https://github.com/php-fig/http-message/compare/1.0...2.0)

---
updated-dependencies:
- dependency-name: psr/http-message
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-23 02:01:53 +01:00
Henrique Moody db11faf129
Improve output of PHPT tests
The `print_r()` is noisy and doesn't show values as they are in PHP, and
using `VarExporter::export()` improved the output a lot.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-02-17 16:33:49 +01:00
Henrique Moody 04b2722d02
Remove ISO 3166-2 data in favor of PHP ISO codes
Keeping the list of ISO 3166-2 up-to-date requires some maintenance. At
the same time, PHP ISO Codes maintains an up-to-date database with even
more ISO codes we could use in this library.

This change doesn't fully use all resources of PHP ISO Codes, but it
already removes some unnecessary code from the repository.

We've already used this library, but it was heavy because it included
all the localizations in it. Now, the package is much smaller (5.0M).

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-02-13 21:53:46 +01:00
Henrique Moody 4a06ed30c0
Upgrade "phpstan/phpstan" to version 1.10
In practice it doesn't change the version, but at least it's up-do-date
in "composer.json".

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-28 15:15:09 +01:00
Henrique Moody 4c33f089fb
Upgrade "respect/stringifier" to version 2.0.0
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-28 14:47:13 +01:00
Henrique Moody 12c145756c
Upgrade "phpunit/phpunit"
This commit also replaces PHPUnit annotations with attributes.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-28 14:16:52 +01:00
Henrique Moody d98d010b77
Upgrade "squizlabs/php_codesniffer"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-27 20:54:19 +01:00
Henrique Moody c6c911cf9f
Upgrade "egulias/email-validator"
The version 3.x hasn't been updated since June 2013.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-27 20:51:37 +01:00
Henrique Moody 16bef2d57b
Upgrade "symfony/polyfill-mbstring"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-27 20:49:59 +01:00
Henrique Moody 24edfda1aa
Drop support for PHP 8.0 and below
PHP 8.0 is no longer supported. Some of our dependencies now do not work
on PHP 8.0 anymore.

This commit will also run tests on PHP 8.3.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-27 20:04:17 +01:00
Henrique Moody 177657d5f4
Upgrade Coding Standards
For now, I'm ignoring many rules because they'll make the changes that
would bring backward compatibility breaks, and I'm aiming to release a
minor version next.

However, upgrading "respect/coding-standard" is necessary because
version 4.0 no longer works.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-27 19:41:12 +01:00
Henrique Moody 8a7bc1ab7a
Improve readability of integration tests
The integration tests use the same pattern to test exception messages.
With my changes, we won't validate which exception we throw in those
tests, but matching the message is enough. I created three functions to
replace most of those tests.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2023-04-01 07:40:42 +02:00
Alexandre Gomes Gaigalas cc3bf86b2f Use libphonenumber
Doing regex on phone numbers is not a great idea. This is a breaking
change, but a good one. Phone validation is now much stricter, and
allows choosing the country.
2023-02-19 00:19:10 -03:00
Alexandre Gomes Gaigalas 8cafa3f298 Drop PHP 7.4 support 2023-02-19 00:19:10 -03:00
dependabot[bot] c6eaf05f47
Update symfony/validator requirement from ^3.0||^4.0 to ^3.0||^4.0||^5.0 (#1400)
Updates the requirements on [symfony/validator](https://github.com/symfony/validator) to permit the latest version.
- [Release notes](https://github.com/symfony/validator/releases)
- [Changelog](https://github.com/symfony/validator/blob/6.2/CHANGELOG.md)
- [Commits](https://github.com/symfony/validator/commits/v5.4.19)

---
updated-dependencies:
- dependency-name: symfony/validator
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-15 04:06:02 +00:00
Alexandre Gomes Gaigalas 15f148da24 Dusting off. See CHANGELOG.md for more details on this commit 2023-02-13 03:59:11 -03:00
Henrique Moody 4c21a7ffc9
Revert "Use "sokil/php-isocodes" on SubdivisionCode"
This reverts commit 9c9c76ebfb.
2021-03-19 15:12:45 +01:00
Henrique Moody 3dcd859d98
Upgrade supported version of "egulias/email-validator"
We could simply add version 3.0 instead of replacing it, but I would
like to stimulate people to keep their libraries up-to-date.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2021-02-06 16:29:39 +01:00
Henrique Moody 9c9c76ebfb
Use "sokil/php-isocodes" on SubdivisionCode
Inside the "data/" directory, we have files with lists of subdivisions
that need to be updated. We have to update them manually, or we automate
that task with a script and GitHub actions.

The two options are very time consuming and also not ideal. We don't
want to deal with that problem and, thinking that the user of this
library may want to show the data that we validate, we should create a
whole library to make it more usable.

The "sokil/php-isocodes" is a simple library that, even supports
translations. It's frequently updated and has gone to major performance
updates.

I am not fond of the idea of requiring an external library to install
Validation, as I have seen that gone wrong before [1]. Ideally, that
would be an optional dependency for people who would like to use those
rules, but to make that happen, we need to release a MAJOR version.

[1]: d072b4de6a

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2021-02-06 15:09:04 +01:00
v0idpwn ff253c78b3
Allow file-related rules to validate PSR-7 interfaces
The PSR-7 has two interfaces that allow us to validate them as files.
This commit will allow some rules to validate those interfaces.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-10-04 12:03:22 +02:00
Henrique Moody f53b77a186
Add support for PHP 8.0
We already supported PHP 8.0 as our constrains in the "composer.json"
file was ">=7.3", but we were not testing it before.

Because of that, I found a bug on "EndsWith" which is fixed now.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-08-28 08:53:41 +02:00
Henrique Moody 72dd88144e
Update version of "respect/coding-standard"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-08-27 16:21:02 +02:00
Henrique Moody 5150428b27
Drop support for PHP 7.2
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-08-26 09:47:48 +02:00
Henrique Moody 642602fd43
Update version of PHPStan packages
Some amazing features had to be ignored because it conflicts with out
coring standards. I hope to soon fix them so we can use PHPStan to its
fullest potential.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-07-25 22:50:59 +02:00
Henrique Moody 3145426472
Update version of "respect/coding-standard"
With that update, we will be fully following PSR-12.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-07-21 22:54:41 +02:00
Henrique Moody b4ad2f6413
Change the PHP support to version 7.2 or aboce
Since there will still be secutiry support until 30 Nov 2020 and there
was something happening in Travis when generating coverage with newer
versions of PHP which I'm not in the mood to debug, I decided to change
the support again, this time to version 7.2.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2020-04-04 23:55:05 +02:00
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 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 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 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 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 1303a935bf
Convert case of "mikey179/vfsstream" package
Package names in Composer should not contain uppercase characters, and
after the version 2.0, it will error.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-23 20:13:12 +02:00
Henrique Moody 166501804f
Refactor "Zend" rule
- Only create objects that are instantiable.

- Validate if validator is a valid Zend Validator after its creation.

- Parse messages from Zend Validator on "assert()" and "check()."

- Upgrade supported version of Zend Validator: version 2.0 has some PHP
  deprecations therefore there is no used to support it.

Co-authored-by: Danilo Correa <danilosilva87@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-03-10 22:13:16 +01:00
Henrique Moody 0c4a278709
Add some code sniffs that we already use
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:07:47 +01:00
Henrique Moody f52097075b
Increase PHPStan level to 2
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-04 00:29:13 +01:00
Henrique Moody b7043b2652
Set up "squizlabs/php_codesniffer"
The tool we used to verify whether the code base has the correct coding
standard was removed [1].

This commit will set up one that works best for us and will also make
sure we have fully compliant to PS1 and PSR2.

[1]: ffec95acda

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-03 19:39:14 +01:00
Henrique Moody 2b86e5443e
Update paths of Composer scripts
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-03 19:01:12 +01:00
Henrique Moody ffec95acda
Remove PHP-CS-Fixer
It is not the first time that after a PHP-CS-Fixer upgrade our build
fails. Also, I've seemed a couple of files that have a wrong coding
standard, but PHP-CS-Fixer does not indicate failure for them.

This commit will remove the library as a dependency.

I plan to introduce PHP_CodeSniffer as soon as possible.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-03 16:26:23 +01:00
Danilo Correa b399bfe1c1
Create Composer scripts to help during development
This commit will create Composer scripts for commands that are
frequently used during the development of the library.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-03 00:04:10 +02:00
Henrique Moody c7fcc09af6
Upgrade PHPUnit version
The changes you see in this commit had to be made due to the upgrade of
PHPunit version.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-03 17:37:44 +02:00
Henrique Moody 258a456eec
Setup PHPStan (PHP Static Analysis Tool)
Require "phpstan/phpstan" for development and add to the Travis CI
configuration file to execute the analysis when Travis executes the
build with the version 7.2 of PHP.

The level of the configuration is very week for now (just "1") and still
quite some changes had to be made in order to make the analysis pass. I
hope it does not take much time to increase the level of the strictness
of the analyses.

I tried to configure that before but because of dependencies with
"symfony/validator" it was not possible.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-22 19:10:20 +02:00
Henrique Moody 1da164a26e
Change how "Sf" rule works
Instead of creating the Symfony constraints itself "Sf" accepts an
instance of "Symfony\Component\Validator\Constraint".

Creating objects inside a rule, specially from an external library,
makes the rule too complex and also limits the possibilities with the
"Sf" rule since Symfony allows users to create complex validations (even
thought their API is not as simple as ours).

This commit also simplifies the way the messages are passed from Symfony
to the "Sf" when only one constraint has failed; instead of passing
the message of the whole constraint violation list, only the fist
constraint violation message it passed.

The problem that this rule will always have is that when using "Not" to
invert the validation we have a way to get a proper message since
Symfony Validator only return the result of constraints that failed.
That's something the Respect\Validation does in a similar way and to
change it a lot has to be changed.

These changes were checked in "symfony/validator" 4.0 and the version
was added to the "composer.json" file.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-22 17:46:21 +02:00
Burhan Ali f03a09aa24 Replace fabpot/php-cs-fixer with friendsofphp/php-cs-fixer
The fapbot version is abandoned accord to packagist and suggests the
friendsofphp version.
2018-03-08 13:11:30 +00:00
Henrique Moody a796d9e981
Update license to MIT 2018-03-03 19:06:38 +01:00
Henrique Moody fe3654b270
Improve RuleTestCase class
- Add documentation to the class and its methods;
- Move RuleTestCase to Test namespace;
- Use PHP 7 type hinting;
- Rename getRuleMock() to createValidatableMock().
2018-01-07 14:32:05 +01:00