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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
The "IpException" was triggering an error when the parameters
"networkRange" or "min" were not defined.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
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.
If calling the method `getExceptionForPath()` when the exception was
nested but had no child it was returning null. This commit ensures that
it always return a valid exception.
Then using the `findMessages()` method, tries to use the method
`getRelatedByName()` before using the `findRelated()` method.
This change was made because since on `KeyNested` rule you may have
names with '.' we'll never get the proper exception using
`findRelated()`.
When you define the name for an `AbstractRelated` instance, you expect
that it also define the name for its child. But, when the child already
had a name the `AbstractRelated` was overwriting its name with the
`reference`.