Commit graph

1250 commits

Author SHA1 Message Date
The Respect Panda 967f7b6cc7 Update Regional Information 2024-04-13 11:45:55 +02:00
Henrique Moody 263ae118fb
Do not validate phone numbers from other regions
I'm unsure whether this is a bug in "libphonenumber-for-php" or if we're
misusing the library. This commit will ensure that only phone numbers
from a specific region will be considered valid. I've reported the issue
to "libphonenumber-for-php" anyways [1].

[1]: https://github.com/giggsey/libphonenumber-for-php/issues/621

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-24 19:49:24 +01:00
The Respect Panda ccec34cf21 Update Regional Information 2024-03-15 11:45:30 +01:00
Henrique Moody 955405b997
Fix type in HexRgbColor documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-11 23:14:36 +01:00
Henrique Moody 788939e359
Remove backwards compatibility break from Phone rule
In version 2.3, the Phone rule started to require
"giggly/libphonenumber-for-php" as a dependency. That was a backward
compatibility break, but the validation also became stricter, and phone
numbers without country codes would not be considered valid.

This commit will revert the backward compatibility break. That way, when
validating a phone number without a country code (the behaviour from
version 2.2), the Phone will not use an external library.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-11 22:14:03 +01:00
Henrique Moody fb322df1da
Use "ParameterStringifier" to stringify input
The idea of the "ParameterStringifier" is to convert any value to a
string. However, we use the "stringify" function directly when
converting the input into a string. That defies the purpose of the
ParameterStringifier, as it gives the "Formatter" two ways of converting
a value into a string.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-11 20:01:47 +01:00
Henrique Moody 5b7ea866e4
Do not allow lowercase country codes
Country codes in ISO 3166-1 should be in uppercase, and the
`AbstractSearcher` should not change the input to search for a value.

While working on this fix, I also discovered that the
"PublicDomainSuffix" rule would throw an exception if it got a
non-scalar value as an input.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-02-02 16:55:37 +01:00
César de la Cal 4c91e3397a
Fix wrong type in "KeySet" rule
The documentation states that we should use Validator::keySet() in
combination with Validator::key() but the return type of key() does not
match the expected parameter type of keyset().

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-28 14:55:45 +01:00
Alan Taylor 8d7d783698
Check if property is initialized before getting its value
This commit also removed the use of "setAccessible", since it's not
neccessary after PHP 8.1.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-27 20:36:01 +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
The Respect Panda 703f610ee8 Update Regional Information 2023-06-13 21:46:15 -03:00
Henrique Moody 003830b8e9
Standardize exception messages
Most exception messages in Validation use "must" and "must not" in their
templates, but a few rules don't.

I fixed most of them, but AlwaysValid and AlwaysInvalid remain because I
wonder if they will be better if I update them.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2023-04-01 05:54:52 +02:00
Henrique Moody 830ad97126
Fix the typo on the "Exists" rule's exception
When I created that rule, I barely spoke English.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2023-03-22 20:39:02 +01:00
github-actions[bot] dd053f2eea
Update Regional Information (#1414)
Co-authored-by: The Respect Panda <therespectpanda@gmail.com>
2023-03-19 05:35:32 +00:00
Henrique Moody 508566eafc
Update list of rules in the chained validator (#1411)
The "bic" rule has been removed, and two more rules were added.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2023-03-10 14:42:27 +00:00
github-actions[bot] 2080e0d2fb
Update Regional Information (#1410)
Co-authored-by: The Respect Panda <therespectpanda@gmail.com>
2023-03-09 00:51:45 +00:00
Alexandre Gomes Gaigalas 636906fa07 Fixed previously introduced bug, add integration test 2023-02-19 22:11:35 -03:00
Alexandre Gomes Gaigalas bae314dd00 Do not hide messages on EachException 2023-02-19 15:26:07 -03:00
Alexandre Gomes Gaigalas 5fe4b96ebf Stricter date format validation 2023-02-19 15:00:47 -03:00
Alexandre Gomes Gaigalas ce9608d0a8 Auto update postal code list
- For this particular updater, a list of exceptions to the rules
   downloaded by geonames is included in POSTAL_CODES_EXTRA, for
   cases in which we seem to do better than geonames itself based
   on previous user reports.
 - Added an option to also validate formatting of the postal codes.
 - Combined multiple PR bots into a single one.
2023-02-19 00:19:10 -03:00
Alexandre Gomes Gaigalas e2b6138bf6 Add PublicDomainSuffix Rule
- List will be auto-updated from https://publicsuffix.org/list/public_suffix_list.dat
 - Updated AbstractSearcher rules to be case insensitive
 - Updated PR creator bots
 - Docs and tests
2023-02-19 00:19:10 -03:00
Alexandre Gomes Gaigalas 6173757f63 Use PHP files and setup a runtime cache for CountryInfo
Previously, we were loading country info from a JSON file. This
changes it to use PHP files instead. It also caches these resources
across calls avoiding these files to be loaded more than once
per process.
2023-02-19 00:19:10 -03: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 fc8230acef Make KeySet impossible to wrap in not(), fix structure message
The use case for negating a keyset is very confusing, and can
lead to validators that don't do what they expect.

This commit introduces NonNegatable rules, which will throw
a Component exception if you try to wrap them in `Not`.

This change was necessary to ensure proper message reporting
when extra keys exist on the keyset.

This fixes #1349
2023-02-19 00:19:10 -03:00
Alexandre Gomes Gaigalas 727e7ccbfa Increase phpstan level from 7 to 8
- Fixed all phpstan errors and ignoreds.
 - False positives now have a "Why:" comment on phpstan config.
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
Alexandre Gomes Gaigalas ab3732f91f Use SPDX IDs for licensing
SPDX IDs are shorter than licensing notes previously used, and
adhere better to FOSS standards. It is also machine-readable.
2023-02-19 00:19:10 -03:00
Alexandre Gomes Gaigalas ef4778b456 Remove version info from Tld.php
We currently use a GitHub action to automate updating this file.

That action has the ability to ignore making the PR if the file
didn't changed.

Having the version number, which changed a line, was causing
several useless PR.

Users can still check if Tld.php changed by seeing the git log,
and a manual note should be issued by the maintainer on the
CHANGELOG.md file when a release containing such changes is
made.
2023-02-19 00:19:09 -03:00
Alexandre Gomes Gaigalas 689026fc7b Improve FilterVar with FILTER_VALIDATE_* options
The `filter_var` function is more of a sanitizer, but we as
a validation library do not care for that use case.

We should treat its sanitizings as a signal for checking if
the type after sanitization matches the option provided.

This fixes #1387
2023-02-19 00:19:09 -03:00
Alexandre Gomes Gaigalas f080f7da08 Improve auto-updaters and pull requesters, auto-tld fix 2023-02-15 00:49:09 -03:00
Alexandre Gomes Gaigalas 1481c8e1e5 Updated docheaders 2023-02-13 19:24:37 -03:00
Alexandre Gomes Gaigalas 9ae39de44e Updates for IntVal changes 2023-02-13 19:21:42 -03:00
Alexandre Gomes Gaigalas 74d7f037a4 Merge branch 'omega3000/master' into 2.2 2023-02-13 19:07:48 -03:00
Alexandre Gomes Gaigalas 2c5793a000 Updated CHANGELOG.md, small phpcs fixes 2023-02-13 19:06:26 -03:00
Alexandre Gomes Gaigalas 13f20e7516 Merge branch 'rule/portuguese_nif_rule' into 2.2 2023-02-13 19:02:10 -03:00
Alexandre Gomes Gaigalas e5223a0913 Merge branch 'scruwi/master' into 2.2 2023-02-13 19:00:28 -03:00
Alexandre Gomes Gaigalas 2951dfd342 General fixes for PR#1392 (rupay card validation) 2023-02-13 18:59:09 -03:00
Alexandre Gomes Gaigalas 8e345b798a Merge branch 'rupay-card-validation' into 2.2 2023-02-13 18:53:04 -03:00
Alexandre Gomes Gaigalas 15f148da24 Dusting off. See CHANGELOG.md for more details on this commit 2023-02-13 03:59:11 -03:00
Ayesh Karunaratne 746c755d14
Use json_validate in Rules\Json if available (#1394)
[`json_validate` function](https://wiki.php.net/rfc/json_validate)
[added in PHP 8.3](https://php.watch/versions/8.3/json_validate) validates a
given string input to contain valid JSON without decoding it in memory.

This adds a function availability check to `Rules\Json`, and uses the new
function instead of decoding the given input, followed by a last-error check.
2023-02-13 04:43:32 +00:00
Rakshit c215761890
Added RuPay card validation 2022-10-22 13:43:16 +05:30
toxxxa c7a6f2ebec Fix Decimal rule for float values > 10 2022-06-29 23:01:42 +03:00
Gonçalo Andrade e219da2945 Add rule for validating portuguese fiscal numbers 2022-06-08 14:29:19 +01:00
Ondřej Vodáček bf4082d208
fix phpdoc type for KeySet constructor (#1365)
by @voda
2022-01-19 12:40:08 +02:00
Fabian Wiget 60566e2250
Fix E_DEPRECATED warning in IntVal rule on PHP 8.1 (#1374)
by @fabacino
2022-01-19 12:38:23 +02:00
Fabian Wiget 4847fe45ff
Fix check whether start and end address have been set in Ip rule (#1375)
by @fabacino
2022-01-19 12:36:13 +02:00
Markus.Lauer b8ee424082 Allow 5- and 6-digit postal code for Cambodia 2021-08-27 17:13:03 +02:00
Alexander Wühr 660294128f
IntVal: Validate negative numbers properly 2021-05-05 13:34:57 +02: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 745a5712eb
Revert "Use "sokil/php-isocodes" on CurrencyCode"
This reverts commit f9b9dd21f9.
2021-03-19 15:12:44 +01:00