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>
This commit will put the quality assurance tools that Travis executes
into a different stage.
It will make the build time increase in approximately one minute, but
the configuration will be way more explicit than it is today.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
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>
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>
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>
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>
PHPT tests are expensive, having all and only the necessary tests in one
single file make more sense.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
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>
This commit will also apply the contribution guidelines to the rule and
improve its documentation.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
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>
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>
- 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>
PHPT files are amazing, but they are also expensive to execute. Having
just one single file running the necessary tests is best than having one
file per test.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
Whenever is possible it is better to declare our classes as final. The
PHPUnit tests should not be extended, therefore there is no reason for
them to not be final.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>