Commit graph

1250 commits

Author SHA1 Message Date
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 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 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 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 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 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 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
Henrique Moody 2ac0aecf0c
Fix some issues with the "KeyValue" rule
There are a couple of issues with the "KeyValue" rule:

* When using it with "Not" it does not fetch the exception from the rule
  that it creates during the validation.

* It creates a "Validator" rule, which means that it creates two rules
  (Validator and the real rule) every time it validates an input.

This commit will fix these two issues and also create integration tests
that will ensure its behavior in case of change.

Co-authored-by: Danilo Correa <danilosilva87@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-23 19:55:13 +02:00
Henrique Moody 718bacad04
Remove subdivision code rules per country
There is no much benefit from having individual rules for each country's
subdivision, quite the opposite. It increases the amount of code and
makes it hard to change the implementation of these rules. Right now,
the only sane way to change those rules is with a customized script.

This commit will remove the Subdivision Code rules per country and
instead will put that information into JSON files.

We both wouldn't like to keep this in this library anymore, and we are
considering having another library to deal with this data [1], but since
it seems like it may take some time, looks better to do it temporarily
here.

[1]: https://github.com/sokil/php-isocodes/issues/12

Co-authored-by: Mazen Touati <mazen_touati@hotmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-06 23:05:24 +02:00
Henrique Moody 1b844763a9
Improve message when nested "Not" rules fail
When using nested "Not" and "AllOf" rules Validation does not fetch the
message of the rule that failed, and instead it fetches the default
message in "AllOfException."

That is because "Not" cannot reach the rules inside "AllOf," making it
impossible to fetch the correct message.

This commit will improve that a bit but making "Not" deal directly with
the rule inside "AllOf" when it has only one rule.

Unfortunately, it will not fix all the issues. For example, when the
negated rule is an "AllOf" with multiple rules and it fails "Not" will
fetch only the first message.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 23:32:31 +02:00
Henrique Moody 51f157605d
Make "NotEmpty" a final class
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 20:28:58 +02:00
Henrique Moody 7b53d54931
Apply contribution guidelines to "No" rule
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 20:25:00 +02:00
Henrique Moody 22f3f80f4c
Make some improvements to the "Roman" rule
The rule validates any empty string as a valid input, its exception
message states Roman with lower-case "R" and refers to numbers instead
of numerals, which is the most common usage.

This commit will fix both behaviors and also improve the tests for the
rule.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 20:15:46 +02:00
Henrique Moody cb528ae612
Apply contribution guidelines to "Xdigit" rule
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 20:09:17 +02:00
Henrique Moody 18ce48371c
Allow hex RGB colors with 3 integers
This commit will also apply the contribution guidelines to the rule and
improve its  documentation.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 19:05:53 +02:00
Henrique Moody 6040ddee42
Fix the case of the "@inheritDoc" tag
According to the official documentation [1] the correct way of writing
the "inheritDoc" tag is with the uppercase "D".

[1]: https://docs.phpdoc.org/guides/inheritance.html

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 19:02:12 +02:00
Henrique Moody cd2390a9b0
Refactor "Domain" rule
The "Domain" rule duplicates a lot of its logic among the methods
"check()," "validate()," and "assert()." Such duplication makes it hard
to maintain and hard to understand.

Besides that:

- It triggers a PHP error when trying to validate a non-scalar value;

- It does not show the exceptions in the correct hierarchy;

- It allows to change the TLD validation after to object is created.

This commit will fix those issues and create better tests for the rule.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-04-05 18:57:22 +02:00
Henrique Moody 81ce5b090b
Merge branch '1.1' 2019-03-31 15:40:12 +02:00
Daniel Alt 9bafee191d
Fix Irish postal code validation
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-03-31 15:27:49 +02:00
Mazen Touati 9dca4bde60
Add inclusive messages to LengthException 2019-03-31 00:50:24 +01:00
Paulo Dias f246939221 Fix bug to validate "01234567890" input in CPF rule 2019-03-29 13:26:36 -03: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 1f6c821fb6
Refactor "Sorted" rule
The sorted rule accepts a callback on its constructor that may be used
to filter values from inside the input. However, with the "Call" rule
one can archive almost the same result. Besides that particular
characteristic, its constructor accepts a boolean value to determine
whether the sorting is ascending or descending.

This commit will remove the callback from the constructor and replace
the boolean by a string which can be "ASC" or "DESC."

Along with those changes, this change will make a few more improvements:

- Make the exception message specific about the sorting direction;

- Allow the rule to validate also strings;

- Update documentation.

Co-authored-by: Danilo Correa <danilosilva87@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-03-10 18:31:03 +01:00
Danilo Correa 5444ab5b0a
Apply contribution guidelines to "Size" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-03-10 18:07:39 +01:00
Danilo Correa b98a7ac89b
Apply contribution guidelines to "Vowel" rule
After writing the integration tests of the "Vowel" rule we noticed that
it is generating extra double-quotes for the "{{additionalChars}}"
template placeholder.

Besides, it considers any whitespace as valid. That is because in the
past Validation would always consider spaces as a valid.

This commit will also remove the extra double-quotes and do not allow
whitespaces to be considered as valid.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-03-10 18:07:39 +01:00
Danilo Correa 18bdd399d7
Apply contribution guidelines to "StartsWith" rule
After writing the integration tests of the "StartsWith" rule we noticed
that it is generating extra parentheses for the "{{startValue}}"
template placeholder.

This commit will also remove those extra parentheses.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-03-10 18:07:39 +01:00
Danilo Correa d2c4912582
Apply contribution guidelines to "Space" rule
After writing the integration tests of the "Space" rule we noticed that
it is generating extra double-quotes for the "{{additionalChars}}"
template placeholder.

This commit will also remove those extra double-quotes.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-03-10 18:07:36 +01:00
Henrique Moody b340b74cfd
Make classes final
The rules "AllOf," "NotEmpty," and "Xdigit" cannot be final because
other rules extend them.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-17 20:13:27 +01:00
Henrique Moody c60ca7937b
Update the Coding Standards
This commit will add a couple of rules that we already use but also
introduce new ones and make sure all the code is in accordance with the
new coding standards.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-17 19:52:26 +01:00
Danilo Correa d63983e2d2
Apply contribution guidelines to "Slug" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-17 19:21:25 +01:00
Danilo Correa 540c0a4a17
Apply contribution guidelines to "Punct" rule
After writing the integration tests of the "Punct" rule we noticed that
it is generating extra double-quotes for the "{{additionalChars}}"
template placeholder.

This commit will also remove those extra double-quotes.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-17 19:21:14 +01:00
Danilo Correa e62d4e145d
Apply contribution guidelines to "Phone" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-17 19:21:14 +01:00
Danilo Correa 9f9b33a36c
Apply contribution guidelines to "NfeAccessKey" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-17 19:21:14 +01:00
Henrique Moody 21aa8eec62
Apply contribution guidelines to "PostalCode" rule
This commit will also remove the second argument from the constructor of
the rule because there is no much use for that, instead if will simply
perform the CountryCode validation.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-17 19:21:14 +01:00
Mazen Touati 6d3eb6afed
Create "Iban" rule
The validation procedure is adhering to what is described in Wikipedia.

Link: https://en.wikipedia.org/wiki/International_Bank_Account_Number#Validating_the_IBAN
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-10 12:54:54 +01:00
Mazen Touati 3723a124c8
Fix NoWhitespaceException typo 2019-02-10 12:52:24 +01:00
Mazen Touati a8cb87217f
Make the ranges of emoji more accurate
The new ranges are now 100% accurate by not including any Unicode point
that is not defined into the reference file.

For example, in the old ranges there is this interval:

    [\x{3297}-\x{3299}]

That is not accurate because there is no "3298" Unicode point in the
specs. It may be used by another character and it will cause the check
to fail if the user included that particular character.

The new ranges for that previous example are now:

    \x{3297}
    \x{3299}

And so on...

This commit will make the ranges more accurate with maximum tolerance to
other charcters and also rename the constant name from "GROUPS" to
"RANGES" since they are ranges, not groups.
2019-02-10 12:44:51 +01:00
Danilo Correa fc433ad449
Apply contribution guidelines to "Graph" rule
After writing the integration tests of the "Graph" rule we noticed that
it is generating extra double-quotes for the "{{additionalChars}}"
template placeholder.

This commit will also remove those extra double-quotes.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-10 12:25:11 +01:00
Danilo Correa ffc349cb03
Apply contribution guidelines to "Consonant" rule
After seeing the integration tests of the "Consonant" rule we noticed
that it is generating extra double-quotes for the "{{additionalChars}}"
template placeholder.

This commit will also remove those extra double-quotes.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-10 12:21:40 +01:00
Danilo Correa 74c3d1acc3
Apply contribution guidelines to "Cntrl" rule
After writing the integration tests of the "Cntrl" rule we noticed that
it is generating extra double-quotes for the "{{additionalChars}}"
template placeholder.

This commit will also remove those extra double-quotes.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-10 12:21:09 +01:00
Henrique Moody 4ab037ed87
Apply "SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:24:08 +01:00
Henrique Moody 85e6af6fcd
Apply "SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:23:09 +01:00
Henrique Moody 81a77ae125
Apply "SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:22:31 +01:00
Henrique Moody 454096c459
Apply "SlevomatCodingStandard.PHP.ShortList"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:21:23 +01:00
Henrique Moody e8a50ea31b
Apply "SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:20:47 +01:00
Henrique Moody 99b912ff87
Apply "SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:19:22 +01:00
Henrique Moody 3abf64f496
Apply "SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:18:59 +01:00
Henrique Moody e500222f5b
Apply "SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:18:30 +01:00
Henrique Moody 750cfa217a
Apply "SlevomatCodingStandard.ControlStructures.ControlStructureSpacing"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:18:01 +01:00
Henrique Moody 147804287b
Apply "SlevomatCodingStandard.Variables.UnusedVariable"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:16:01 +01:00
Henrique Moody e89b32270b
Apply "SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:15:39 +01:00
Henrique Moody 44f4d65a3d
Apply "SlevomatCodingStandard.PHP.UselessParentheses"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:15:06 +01:00
Henrique Moody 751e08c9f0
Apply "SlevomatCodingStandard.Namespaces.UnusedUses"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:14:28 +01:00
Henrique Moody 880103c55f
Apply "SlevomatCodingStandard.Functions.StaticClosure"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:13:35 +01:00
Henrique Moody d72d247ddc
Apply "SlevomatCodingStandard.ControlStructures.EarlyExit"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:13:06 +01:00
Henrique Moody 7e3bf36f8d
Apply "SlevomatCodingStandard.ControlStructures.AssignmentInCondition"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:12:38 +01:00
Henrique Moody cb24cc97d2
Apply "SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:12:05 +01:00
Henrique Moody cbe484a4d3
Apply "SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:10:01 +01:00
Henrique Moody 7e884cc0f4
Apply "SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:09:29 +01:00
Henrique Moody c30603759e
Apply "SlevomatCodingStandard.TypeHints.TypeHintDeclaration"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:09:28 +01:00
Henrique Moody 0e0581a9da
Apply "Squiz.WhiteSpace.OperatorSpacing"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:08:43 +01:00
Henrique Moody 8e59ec5d4a
Apply "Squiz.WhiteSpace.MemberVarSpacing"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:08:43 +01:00
Henrique Moody ee1d49a2cf
Apply "Squiz.PHP.CommentedOutCode"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:08:41 +01:00
Henrique Moody 5bdffaa51b
Apply "Generic.Arrays.ArrayIndent"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-09 14:07:52 +01:00
Henrique Moody 985b6fac25
Increate PHPStan level to 7
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-04 01:12:08 +01:00
Henrique Moody 4519739f8b
Increate PHPStan level to 6
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-04 01:09:49 +01:00
Henrique Moody 103a47e134
Increate PHPStan level to 5
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-04 00:49:35 +01:00
Henrique Moody b007284857
Increate PHPStan level to 3
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-04 00:44:08 +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
Mazen Touati 9c7550aa43
Create "NotEmoji" rule
The data in this commit has been gathered, scrapped, organized and
treated based on the Emoji Unicode V11 specification [1].

[1]: https://unicode.org/Public/emoji/11.0/emoji-test.txt

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2019-02-03 17:51:55 +01:00
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 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
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 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
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
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 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
Danilo Correa 083ccec068
Apply contribution guidelines to "LeapYear" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-14 08:41:14 +02:00
Danilo Correa 5b6184d4e2
Apply contribution guidelines to "NotOptional" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-14 08:40:32 +02:00
Henrique Moody 9283c8ecd9
Do not accept whitespace by default in "Digit" rule
The "Digit" rule is meant to validate digits. However, by default, it
also considers any whitespace character (spaces, new lines, tabs, etc)
as valid.

Since the rule also accepts a list of characters to ignore during the
validation it seemed logical to me to leave the responsibility of
allowing whitespace characters on the hands of the one who uses the
rule.

The messages of the exception are not really consistent, this commit
will also fix that.

It's also clear that the "AbstractCtypeRule" is an unnecessary overhead
since it is only a proxy for "AbstractFilterRule". That one can and
should even be removed after this commit is applied especially because
this commit will also remove the method "filterWhiteSpaceOption" which
is the only substantial difference between "AbstractCtypeRule" and
"AbstractFilterRule".

This commit will also apply our guidelines to the "Digit" rule since we
want to do that to all the rules we have.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-12 10:00:17 +02:00
Henrique Moody 27bd5d204d
Do not accept whitespace by default in "Alpha" rule
The intent of the "Alpha" rule is to validate alphabetic values.
However, it also considers any whitespace character (by default). That
causes some confusion, and unless you check its code or tests, you would
never expect that behavior.

Because of that confusion, I decided to make "Alpha" to not consider
whitespace characters as valid, and since in the constructor of this
rule it's possible to add extra characters to the validation it makes
sense to let the user decide whether they want whitespaces, tabs, new
lines, etc. or not.

This rule, as the same as "Alnum" previously, extends
"AbstractCtypeRule" pretty much to only make it easier to consider any
whitespaces as valid, therefore I saw no reason to keep extending it.
Now "Alpha" extends the "AbstractFilterRule" which is the parent of
"AbstractCtypeRule".

I also took the opportunity to apply our contribution guidelines to
"Alpha" since we want to apply that to all the rules.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-11 11:38:15 +02:00
Henrique Moody 3601adf6db
Create "FilteredValidationException" class
All the classes that were extending "AbstractFilterRule" were throwing
exceptions that were extending "AlphaException". That can cause some
issues when the user has a validation chain with "Alpha" and another
child of "AbstractFilterRule" and expects "AlphaException" specifically.

This commit creates "FilteredValidationException" that can be used as
the parent of the exceptions thrown by rules that extend the class
"AbstractFilterRule".

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-11 11:02:17 +02:00
Danilo Correa 24040c9473 Apply contribution guidelines to "NotBlank" rule 2018-09-10 21:00:53 -03:00
Danilo Correa 0e67549dd9
Apply contribution guidelines to "Pesel" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-10 14:51:52 +02:00
Danilo Benevides 2bb6f66251
Apply contribution guidelines to "LeapDate" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-10 14:51:52 +02:00
Danilo Correa 73a0107349
Apply contribution guidelines to "PhpLabel" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-10 08:18:15 +02:00
Danilo Correa 30993fc4a0
Apply contribution guidelines to "Pis" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-10 08:16:25 +02:00
Danilo Correa e832a99d4c
Apply contribution guidelines to "StringVal" rule
Also creates a "ToStringStub" class to help on testing objects that can
be converted to string.

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-06 08:41:12 +02:00
Danilo Correa c7fbded457
Apply contribution guidelines to "NumericVal" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-06 08:41:11 +02:00
Danilo Correa 17f8c50f54
Apply contribution guidelines to "Length" rule
Because of the type hinting some validation could be removed from the
"length" constructor.

While applying the contribution guidelines we could also see some
duplicated logic in the "extractLength" method and that the rule was
validating

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-06 08:41:11 +02:00
Henrique Moody 779c0c1503
Do not accept whitespace by default in "Alnum" rule
The "Alnum" rule is supposed to validate alphanumeric values, but
instead, it also validates any whitespace character as valid.

The rule also accepts a list of characters on its constructor, so it the
users intentionally want some specific characters to also be allowed it
is better than they also defined these characters on the rule's
constructor.

While refactoring the rule I could notice that "AbstractCtypeRule" is
just an overhead that does not add much to it, so instead of extending
it "Alnum" now extends "AbstractFilterRule" directly (which is the
parent of "AbstractCtypeRule").

And since we want all rules to follow our contribution guidelines, this
commit also make sure the "Alnum" rule is in accordance with that.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-04 00:05:24 +02:00
Danilo Benevides 9a8cac06d7 Apply contribution guidelines to "Json" rule 2018-08-30 23:08:27 -03: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 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 f5c167c411
Merge branch '1.1' 2018-08-22 19:09:55 +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
Henrique Moody fe7fed3461
Remove support "egulias/email-validator" ~1.0
The rule "Email" now only supports the version >=2.0 of
"egulias/email-validator". Also a few changes were made to make the rule
a bit simpler.

The method "getEmailValidator()" which was a lazy load of the
"EmailValidator" class was removed in favor of trying to create the
instance of "EmailValidator" in the constructor of "Email". That makes
the rule immutable after its creation.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-22 17:22:46 +02:00
Henrique Moody d64d26c681
Intercept throwables in the "Call" rule
The callable defined to the "Call" rule may also throw an exception and
as we don't want to have errors nor exceptions that are not part of the
Validation during the validation of inputs it just makes sense to
intercept any instance of Throwable.

This change was initially thought of because in Travis the version 7.4
of PHP was throwing "Error" instead of triggering PHP errors which made
the tests fail.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-22 17:04:20 +02:00
Henrique Moody 2fac861aa1
Do not trigger PHP errors in the "Call" rule
This commit make sure that when the callable is executed by the "Call"
rule and PHP triggers an error, the user does not have to deal with it,
and instead the rule will throw "CallException".

Because of the many changes that were made, it didn't make sense to keep
the class "Call" extending the "AbstractRelated" class.

One thing that is a bit problematic with this rule - and with other
rules as well - is that Validation only knows details of a validation
when it fails, because of that we cannot invert the validations that
passed, meaning that the "Not" rule cannot give the proper response to
a validation that passed. This is a know issue that can only be fixed
is we provide a way for Validation do have more granularity control.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-21 01:22:38 +02:00
Danilo Benevides 2b8acfd790 Apply contribution guidelines to "In" rule 2018-08-19 16:01:10 -03: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
Danilo Benevides d022a71f54
Apply contribution guidelines to "Instance" rule
Also updates how the tests define the name of the instance by using the
class keyword [1] instead of a string with the class. That is useful
in code analyses be able to identify the usage of these
classes/interfaces.

[1] http://php.net/class#language.oop5.basic.class.class

Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-16 21:54:17 +02:00
Ismael Elias fad0005fa0
Apply contribution guidelines to "Number" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-16 21:54:17 +02:00
Danilo Benevides 94d2e87b2a
Apply contribution guidelines to "Infinite" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-16 21:54:16 +02:00
Danilo Benevides f01972e208
Apply contribution guidelines to "Imei" rule
Co-authored-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-16 21:54:16 +02:00
Henrique Moody afab4eb2b4
Rename "Related" to "Child"
The "NestedValidationException" has exceptions that are its children.
However, we call them "related". This commit updates the term over the
library.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-02 11:18:33 +02:00
Henrique Moody a1bc0cd6b4
Apply contribution guidelines to "NestedValidationException"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-02 11:11:04 +02:00
Henrique Moody 3ad35ed545
Remove unneessary information from iterator
In the iterator in the "NestedValidationException" the only information
that is necessary is the depth of the message, for that reason all the
other information can (and should) be removed.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-02 11:09:30 +02:00
Henrique Moody da10941ddc
Apply contribution guidelines to "Validator" class
Also removes the possibility of the "create()" method to create a new
Validation with predefined rules since that is the behavior that the
constructor already has.

And even though may be a bit scary to make "Validator" final I believe
there should be no reason for this class to be extended, and if there is
it is probably because we are missing something, which I would very much
like to find out.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-08-02 10:37:38 +02:00