Commit graph

1424 commits

Author SHA1 Message Date
Henrique Moody dbf5dc33d0
Create MkDocs configuration file
In order to customize the "theme" and be able to test it locally.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-11 09:25:41 +01:00
Lee Hesselden 780233a44b
Updated documentation about custom rules
The documentation about custom rules does not specify that creating an
exception for the rule is necessary. This commit will add that to the
documentation with an example to make it explicit.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-02 11:23:04 +01:00
Henrique Moody 66f5475463
Update PHP support
Due to the current status of the development of the library, it seems
like we will be supporting version 1.1 for a long time. Even when we
release version 2.0 we will still give support for version 1.1 for a
while.

This commit will make sure that version 1.1 is fully supported for PHP
7.2 and 7.3. Also, it will remove the support for HHVM since it will not
keep the compatibility with PHP anymore [1].

In order to make that happen, this commit will create a TestCase from
Validation so we can use the same API to create mocks in both PHPUnit
versions 4.0 and 5.0.

During the development of this commit, I noticed that PHPUnit 4.0 had
issues to mock "SplFileInfo" and for that reason, this commit will also
replace those mocks by "SplFileInfo" instances.

[1]: https://hhvm.com/blog/2018/09/12/end-of-php-support-future-of-hack.html

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-02 11:09:24 +01:00
Brian Johnson f8c90fa368
Fix Regex for Canadian postal code
Removes the errant space in the CA PostalCode regex.
This space was introduced by 5a067fa.

It also adds unit tests for the CA PostalCode to validate
the fix.

Reviewed-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
2018-11-04 22:58:45 +01:00
Linus Metzler 48b06254c4 Fix license identifier
Currently the license identifier (BSD Style) does not comform to the
SPDX list of valid identifiers https://spdx.org/licenses/. Having a
valid identifier helps automated license checking tools verify your
package.

I took the liberty of setting the license to BSD-3-Clause. If you want
to allow multiple licenses, you could use a SPDX expression e.g.
(BSD-2-Clause OR BSD-3-Clause).
2018-10-11 14:18:10 +02:00
ong-ar 892b39e5ff
Update Korean postal code validation
The Korea Postal code system changed from a 6-digit postal code system
to a 5-digit postal code system on August 1, 2015 [1] [2].

This commit makes sure that the "PostalCode" rule validates Korean
postal codes correctly.

[1]: http://www.fedex.com/ky/koreapostalcode/index.html
[2]: http://www.epost.go.kr/roadAreaCdEng.retrieveLnEngAreaCdList.comm

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-10 20:51:31 +02:00
Henrique Moody 203f8e7e9d
Update TLD list with version 2018100800 from IANA
As it seems, the TLDs "goodhands", "jlc", "panerai", "statoil",
"telecity", and "vista" were removed from the list.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-09 06:03:51 +02:00
Konstantin c9850f4ec7
Make sure that "Email" only validates strings
There shouldn't be possible to consider a non-string value as a valid
email anyways, but the real problem is that the "RFCValidation" from
"egulias/email-validator" casts the input as a string which makes PHP
trigger an error.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-09 05:28:51 +02:00
Henrique Moody 5a067faec7
Update "PostalCode" list
Updated the whole list according to the last version found on
geonames.org.

The script that I executed to generate the list is:

curl -L http://download.geonames.org/export/dump/countryInfo.txt |
  sed 's,\t,\;,g' |
  sort -u |
  cut -d ';' -f 1,15 |
  sed -E "/^#/d; /^[A-Z]{2}\;$/d; s,([A-Z]{2})\;(.+),'\1' => '/\2/'\,,g"

After generating the list I few changes had to be made since some of the
postal codes in the list were manually updated because they were not
correct.

This change was made because James Macon reported that "110231" was
not recognized as a valid Colombian postal code.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-29 22:30:50 +02:00
Henrique Moody a039d6d4b9
Fix wrong behavior of "Date" rule
The validation was considering "99" as a valid month and neither
date_parse_from_format() [1] or DateTime::createFromFormat() [2] would
complain about that.

The solution for that was to use checkdate() [3] to verify whether the
date is valid or not. Also, an extra step was added to the validation
that a date that only contains a day would return false since a day
without a month and year is impossible to validate.

Apparently, there is no problem while validation when it comes to time,
therefore nothing needed to be added for this validation.

[1]: http://php.net/date_parse_from_format
[2]: http://php.net/datetime.createFromFormat
[3]: http://php.net/checkdate

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-29 21:46:53 +02:00
Henrique Moody 52614d600d
Organize documentation for "Read the Docs"
The current documentation is hosted via GitHub pages rendered by
"Couscous". Every time we need a new version of the documentation
published we need to manually execute the "couscous".

This commit reorganize the documentation to be published to
"Read the Docs" because it will also allow us to have documentations per
version of the library most importantly provider a search field for the
documentation.

The documentation will be then published on:
https://respect-validation.readthedocs.io/

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-23 01:59:39 +02:00
Henrique Moody add542ea48
Update "Tld" rule with IANA's list
This commit will update the list of Top-Level Domains in the "Tld" rule
with the latest version found in the website of IANA (Internet Assigned
Numbers Authority).

The list was created with the commands below:

curl -L curl -L https://data.iana.org/TLD/tlds-alpha-by-domain.txt |
    grep -v '^#' |
    tr '[A-Z]' '[a-z]' |
    sed -E "s,^,',; s/$/', /" |
    tr -d '\n' |
    fold -w 72 -s

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-18 15:10:37 +02:00
Andrei Drulchenko 19d6ec8939 fix IntVal() leading zero behavior 2018-08-01 16:06:54 +03:00
Henrique Moody 47f21596a5
Fix casting error in AbstractInterval classes
The classes that are children of "AbstractInterval" convert their values
before comparing them.

Because PHP tries to convert values when making comparisons and an
"DateTime" object cannot be converted to integer or float some
validations would result into PHP triggering an error like:

> Object of class DateTime could not be converted to int
> Object of class DateTime could not be converted to float

This commit prevents that to happen by verifying if both compared values
are scalar or not before comparing them with each other.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-07-28 05:01:58 +02:00
Axel Wargnier 4f3aa90d1f Fix postalCode for Portugal (PT) 2018-07-25 12:33:08 +02:00
Henrique Moody 667ed36b48
Fix grammatical errors in URL exception message
Although the "U" at the first of URL is a vowel, the abbreviation is
pronounced "you-are-ell". Because the letter "Y" is a consonant in this
case, we should use "a" instead of "an".

Link: https://itknowledgeexchange.techtarget.com/writing-for-business/which-is-correct-a-url-or-an-url/

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-07-02 08:22:41 +02:00
Wojciech Frącz 83bb6e3fc9
Fix wrong behavior when using templates
When a template is set for a chain of rules, does not really matter
which messages the chain can have, the only message to be used should be
the one based on the defined template.

This commit set the same template of a parent rule to its children's
exception. Our first thought was to set the template to its children
however that would mean that if another rule would be added to the chain
we would have to set it as well. Doing that to the children's exception
make sure we only do that once.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-07-02 07:57:21 +02:00
Islam Elshobokshy e70c201691
Make clear that "Alnum" rule accepts whitespaces
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-07-01 14:27:41 +02:00
Sebastian 8fc2484428
Fix postal code for The Netherlands
Postal code for NL allows for a space between the digits and the
letters.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-06-29 01:10:31 +01:00
Henrique Moody 4fdd2da19e
Fix wrong behavior with nested exceptions
Use the same condition to not include child exception into the iterator
to also not show the message of the main exception when using
"getFullMessage()".

The method created to validate that condition should probably be in the
"ValidationException" itself, but this commit is meant to be a bug fix,
which will be released in a PATH version, and creating this public
method would imply that a MINOR version should be released.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-06-29 00:50:27 +01:00
Adam Benson f5ca4a298a
Fix "IntVal" considering boolean values as valid
The commit 54d17ab tried to fix the that "IntVal" would pass with values
that are not considered as an integer, but it does not change

Even thought the commit 54d17ab fixes part of the wrong behaviour it
left out the filter for boolean values.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-06-28 22:09:42 +01:00
Henrique Moody 54d17abcee
Do not consider any float as integer
Values like "500.00" or 1.0 should not be considered as integer values
even though there is no data loss when they're converted to integer.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-06-23 21:15:38 +02:00
Henrique Moody 0e73bc732e
Avoid using unset keys in IpException
The "IpException" was triggering an error when the parameters
"networkRange" or "min" were not defined.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-06-23 21:00:04 +02:00
Mecit fca464615e
Update composer.json
Suggest friendsofphp/php-cs-fixer instead of fabpot/php-cs-fixer which is no longer maintained.
2018-06-20 23:25:11 +03:00
Radoslaw Wesolowski 700e23777f
Added .studio tld
https://icannwiki.org/.studio
2018-06-06 14:57:39 +02:00
Tim Bond 020ea1ebb5
Update type parameters for Validator doc blocks
The "@param" tag uses phpdoc types. However the "@method" tag uses PHP's
type declarations. Therefore, "mixed" refers to a class whose literal
name is mixed and not the "mixed" keyword. Since "mixed" is not a valid
class name in this context, the type paramaters should be removed.

Additionally, the "callable" type paramater can be used on the
"callback" validation method.

References:
[1]: http://docs.phpdoc.org/references/phpdoc/tags/param.html
[2]: http://docs.phpdoc.org/references/phpdoc/types.html
[3]: http://docs.phpdoc.org/references/phpdoc/tags/method.html
[4]: http://php.net/functions.arguments#functions.arguments.type-declaration
[5]: http://docs.phpdoc.org/references/phpdoc/types.html
Reviewed-by: Henrique Moody <henriquemoody@gmail.com>
2018-05-19 16:26:44 +02:00
Tim Bond 4c996258a1
Update NestedValidationException doc block 2018-05-19 16:19:16 +02:00
MacFJA df985765a6
Update French subdivision codes 2018-05-19 16:18:28 +02:00
Henrique Moody cb4fb83b3e
Revert "Elaborated API styles documentation"
This reverts commit eb2621fafe.
2018-05-19 16:17:57 +02:00
Henrique Moody 5c598cdce2
Revert "Add link to support issues."
This reverts commit 62e1170a21.
2018-05-19 16:17:52 +02:00
Henrique Moody c6b6a4c425
Revert "Tested and fixed documentation"
This reverts commit 4357349ff0.
2018-05-19 16:17:47 +02:00
Nick Lombard 4357349ff0
Tested and fixed documentation
Fixed concrete and builder api documentation
2018-04-22 12:35:48 +02:00
Nick Lombard 62e1170a21
Add link to support issues.
Added link issues filtered by label support
2018-04-22 01:33:48 +02:00
Nick Lombard eb2621fafe
Elaborated API styles documentation
Transferred documentation from issue #90 Dynamic chaining
2018-04-22 01:12:42 +02:00
Henrique Moody ee9e69776a
Merge branch '1.0' into 1.1 2018-01-02 22:47:22 +01:00
Henrique Moody c931e2504b
Change conditions for Domain validation
Domains can have `--` as long as they don't start or end with `-` in its
parts.
2018-01-02 22:24:43 +01:00
Henrique Moody 37a71de7d0
Try to find template from default templates first
When executing `ValidationException::setTemplate()` using a template
key, it does not try to select the template, but instead it uses the
template key as the template itself.

In order to fix this behaviour, there is now a check for a key with the
defined template. In case the template was not found, use the defined
template as the template itself.
2018-01-02 21:56:07 +01:00
Henrique Moody d072b4de6a
Remove "malkusch/bav" as dependency
And was that, without warning that the "malkusch/bav" package was
removed from Packagist. This commit removes it as dependency but do not
remove any class that uses it in case there is a user loading the
package from a VCS repository with Composer.
2018-01-02 21:45:22 +01:00
Henrique Moody 22f1f14430
Merge branch '1.0' into 1.1 2017-10-17 12:15:51 +02:00
Henrique Moody 14572537fe
Improve "Phone" rule
- Only allow spaces and not "\t" or "\n";
- Once the number has a "(", it needs a ")".
2017-10-17 09:51:09 +02:00
RCooLeR 191ee47fc0
Update regex of "Phone" rule
Now regex also matches +1 (555) 555 5555
2017-10-17 08:58:47 +02:00
Henrique Moody 631affdbf2
Merge branch '1.0' into 1.1 2017-10-16 10:39:15 +02:00
Tim Strijdhorst c013fac277
Fix currency code for Belarusian Ruble
References:
- https://en.wikipedia.org/wiki/ISO_4217
- http://www.xe.com/iso4217.php
2017-10-16 10:16:47 +02:00
Henrique Moody 658764a47f
Skip MimetypeTest when in HHVM 2017-10-16 10:16:47 +02:00
Jonathan Stewmon 298102ba13 Use annotations for variadic methods 2017-03-27 13:37:47 +02:00
Henrique Moody 5ab87d1dd9
Merge branch '1.0' into 1.1 2017-03-14 10:44:11 +01:00
Henrique Moody dc869ac375
Only return "name" as is if it's a string 2017-03-14 10:28:03 +01:00
Henrique Moody 03f4abbd08
Merge branch '1.0' into 1.1 2017-01-26 15:39:48 +01:00
Yosmany Garcia 8eb95c2b04
Updated provinces of Cuba
Updated provinces of Cuba according to the change of 2011
2017-01-26 15:38:38 +01:00
Michał Prochowski fa61315079
Czech and slovakia postal code patterns fix. 2017-01-26 15:37:37 +01:00