Commit graph

1825 commits

Author SHA1 Message Date
Danilo Correa 54293d4ca2
Apply contribution guidelines to "Regex" rule
Because some classes extend the "Regex" class this commit will also
change the implementation of those classes to use "Regex" by composition
instead of extending the class.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-14 00:15:03 +01:00
Kirill Dlussky 81d71749b7
Create "ContainsAny" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-13 00:11:08 +01:00
Henrique Moody 8fd18d9b72
Fix wrong behavior in the "Contains" rule
While making sure that Validation uses PHP strict types [1] the compared
value in the "Contains" rule was cast to string. That is problematic
when someone wants to enforce the operation to compare if the input has
a value identical to the expected value.

This commit will fix that by not casting the expected value but also
make sure that string comparison will not be used when it's not a
string.

[1]: ef975629f3

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-13 00:09:41 +01:00
Henrique Moody a00617bcad
Merge branch '1.1' 2018-12-11 13:31:50 +01:00
Henrique Moody a009286ba6
Update "See also" section in the rules's documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-11 13:19:52 +01:00
Henrique Moody aae3ae2d14
Merge branch '1.1' 2018-12-11 09:28:37 +01:00
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
Henrique Moody bd63f65c91
Improve code and documentation of "Ip" rule
This commit will do many different things, but they are all improvements
to the "Ip" rules:

* Remove passing variables by reference: the "Ip" class uses that a lot
  to define the start address, end address, and the mask used to
  validate a network range;

* Remove double-typed argument from the constructor: the class "Ip"
  class has only one argument that can be either a string with the range
  of the IP or an integer with options for the "filter_var()" function.
  This commit will split it into two different arguments, each of them
  used for one of this functionalities;

* Update documentation to show how to validate IPv6.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-07 23:32:40 +01:00
Henrique Moody 2aaec39dbb
Apply contribution guidelines to "Ip" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-07 19:43:57 +01:00
Henrique Moody 73f9380d9e
Use a more consisten names for traits
Because traits are behaviors that are added to a class, it makes sense
to name them with the behavior that they add the classes that use them.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-06 21:21:42 +01:00
Gus Antoniassi b392fbb92e
Apply contribution guidelines to "SymbolicLink" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-12-06 20:56:51 +01:00
Henrique Moody ab87cb083d
Merge branch '1.1' 2018-12-05 08:57:05 +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
Henrique Moody df3f1c0ea7
Add "CREDITS" section to PHPT files
All the PHP files have the "@author" annotation to make clear which
people have contributed to that specific file, however, there is no such
thing in the PHPT files.

This commit will add the "CREDITS" section to the PHPT files. The list
of authors is created from the output of the `git blame` command.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-11-30 09:25:42 +01:00
Danilo Correa 54e3f99ec4
Apply contribution guidelines to "When" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-11-25 19:21:29 +01:00
Henrique Moody 9e7571fb98
Add missing "@author" annotations
This commit will make sure that every class, interface, or trait will
have the "@author" annotation in it.

In order to create a list of authors, I used the "git blame" command,
which means that if someone changed or even created the file but does
not have any remaining line will not be shown in the list; it's a
trade-off worth but it is worth it. The other way to do it would be
carefully checking each file.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-11-25 18:08:44 +01:00
Henrique Moody 2e29b9e8c7
Fix "@author" annotations
Some classes and one trait had some mismatch values for their "@author"
annotation and this commit will fix the mismatch putting the correct
authors.

I used the "git blame" command to find out which people changed the file
and created a list based on that information.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-11-25 18:04:59 +01:00
Henrique Moody 93e177a4c0
Make second argument of "AbstractEnvelope" optional
The argument "parameters" which is meant to give the wrapped rule's
exception some extra information does not always need to be defined, for
example when the exception does not need any parameter.

The current version of "AbstractEnvelope" required that argument and the
rules that are extending this class are passing an empty array.

This commit will make the "parameters" argument optional. As an extra,
it will make sure the tests from the children of "AbstractEnvelope" are
also covering their parent.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-11-25 15:30:40 +01:00
Danilo Benevides 9595b3fd6c
Apply contribution guidelines to "LanguageCode" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-11-25 13:27:06 +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
Danilo Correa d6699a3daf
Apply contribution guidelines to "VideoUrl" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Co-authored-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
Co-authored-by: Danilo Correa <danilosilva87@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-26 00:00:45 +02:00
Danilo Correa c871291a55
Apply contribution guidelines to "Writable" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Co-authored-by: Danilo Correa <danilosilva87@gmail.com>
Co-authored-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
2018-10-26 00:00:07 +02:00
Emmerson Siqueira 299551dea3
Add support to Twitch on "VideoUrl" rule (#1154)
Co-authored-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
2018-10-23 16:50:30 +02:00
Henrique Moody 4e045e75b4
Execute PHP 7.3 on Travis
Because "friendsofphp/php-cs-fixer" does not support PHP 7.3 this commit
will also add "--ignore-platform-reqs" argument to Composer when it is
being executed.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-15 11:28:46 +02:00
Henrique Moody c99f3818b7
Use variadics "AbstractFilterRule" rule
Since the library doesn't need to give support to version 5.4 or less of
PHP using variadics in the constructor of "AbstractFilterRule" seems
better than doing the whole validation.

This commit will also apply the contribution guidelines to
"AbstractFilterRule" and use a better naming for it.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-15 09:41:01 +02:00
Michael Weimann 6730576fe4
Add support for specific versions of UUID
This commit will allow validation of UUIDs with versions 1, 3, 4 and 5.

Version 2 was not implemented since its adoption is not that broad and
we couldn't find many details about it.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
2018-10-12 11:37:42 +02: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 d9628a89dd
Merge branch '1.1' 2018-10-09 06:38:43 +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
Danilo Correa fbbab77b24
Apply contribution guidelines to "Version" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-03 00:04:39 +02:00
Danilo Correa 69a01249da
Apply contribution guidelines to "Fibonacci" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-03 00:04:39 +02:00
Danilo Correa 4200704bdc
Apply contribution guidelines to "File" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-03 00:04:39 +02:00
Danilo Correa 23656c9030
Apply contribution guidelines to "Finite" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-03 00:04:39 +02:00
Danilo Correa 0be63bd313
Apply contribution guidelines to "FalseVal" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-03 00:04:38 +02:00
Danilo Correa eb232247da
Apply contribution guidelines to "Factor" rule 2018-10-03 00:04:38 +02: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
Moritz 03ea1b75f6
Create "Isbn" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-02 17:32:08 +02:00
Danilo Correa 4106589e7f
Apply contribution guidelines to "Extension" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-24 21:28:20 +02:00
Danilo Correa 1b4a904871
Apply contribution guidelines to "Luhn" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-24 21:23:17 +02:00
Henrique Moody 478e248dad
Remove unnecessary inheritance from "Yes" rule
The "Yes" rule extends "Regex" rule. The only reasons why that is useful
is because "Yes" uses regular expressions to validate the inputs.

However, the "Yes" rule is way more complex simply validating a regular
expressing and having "Regex" as its parent is also a little bit
misleading.

This commit will:

* Remove unnecessary inheritance from "Yes" rule;

* Improve the documentation of the "Yes" rule;

* Enhance the unit tests of the "Yes" rule.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-16 19:40:48 +02:00
Henrique Moody ea683e691d
Remove "AbstractRegexRule" class
The "AbstractRegexRule" seems like an unnecessary overhead on top of the
"AbstractFilterRule". In fact, the "Phone" and "Uuid" rule should not
even be children of "AbstractFilterRule".

This commit will remove the "AbstractRegexRule" and replace it with
"AbstractFilterRule" on the rules that are depending on it. As for the
rules that don't depend on it it will replace by "AbstractRule" like
most of the other rules.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-16 18:32:39 +02:00
Danilo Correa 907e24fb8f
Apply contribution guidelines to "MacAddress" rule
This commit will also replace the usage of "mac" to "MAC" since it is an
acronym.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-16 18:26:51 +02:00
Danilo Correa e2e9197f29
Apply contribution guidelines to "Mimetype" rule
This commit will also replace the usage of "mime" to "MIME" since it is
an acronym.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-16 18:15:57 +02:00
Cameron Hall fd13b03d18
Apply contribution guidelines to "Yes" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-16 17:25:26 +02:00
Henrique Moody 35f3dd63af
Remove "AbstractCtypeRule" class
The "AbstractCtypeRule" class is an abstraction that is purely an
overhead on top of the "AbstractFilterRule". Not having a real reason to
exist I thought would be better to just remove it and replace its usage
by "AbstractFilterRule".

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-14 09:08:56 +02:00
Danilo Correa d5724c0d9a
Remove "image_5.phpt" file
This file should have been removed by when the contribution guidelines
were applied to "Image" but for some reason, we missed that.

Reference: 861216c690
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-14 08:58:39 +02:00
Danilo Correa aedf261958
Apply contribution guidelines to "Readable" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-14 08:58:39 +02:00