Commit graph

409 commits

Author SHA1 Message Date
Henrique Moody a3c945aa51 Add license information and copyright in all files 2015-06-08 12:09:25 -03:00
Henrique Moody b8c76e3054 Fix some coding standards 2015-06-08 11:51:45 -03:00
Henrique Moody 2c2c838c1a Merge branch '0.9' 2015-05-28 11:32:58 -03:00
Henrique Moody d0f36de3bd Merge branch '0.8' into 0.9 2015-05-28 11:29:15 -03:00
Henrique Moody fa265e3edf Fix wrong behaviour on JSON rule
It was not considering values like `false`, `null`, `[]` or `{}`.
2015-05-28 11:02:07 -03:00
Rans0n 153ca2e4f8 Update Validator.php
Add missing parameter in domain() method signature.
2015-05-15 11:24:51 +02:00
Augusto Pascutti fc08c96971 Prevents noWithespace failing with arrays
A warning was thrown because of the preg_match call, as not every input
is a string we prevent calls from arrays going further into checking.

Issue 346
2015-05-06 00:06:26 -03:00
Augusto Pascutti 84dec918d1 Prevents noWithespace failing with arrays
A warning was thrown because of the preg_match call, as not every input
is a string we prevent calls from arrays going further into checking.

Issue 346
2015-05-06 00:06:09 -03:00
Augusto Pascutti 38cab9950c Prevents noWithespace failing with arrays
A warning was thrown because of the preg_match call, as not every input
is a string we prevent calls from arrays going further into checking.

Issue 346
2015-05-05 22:38:21 -03:00
Henrique Moody cf4ec32481 Remove "Country" rule 2015-04-24 19:26:49 -03:00
Henrique Moody 1b757b3852 Merge branch '0.8' 2015-04-24 19:20:09 -03:00
Henrique Moody 0e9044de81 Merge branch '0.7' into 0.8 2015-04-24 19:19:42 -03:00
qrazi b4bb681fd3 The creation of a DateTime-object from the input-string keeps the given
timezone information. However, in the comparison the DateTime-object is
first output to a timestamp, which is then converted to a string with the
date()-function. But because a timestamp does not include timezone
information, date() will assume the system's timezone. So if the system
timezone set in the PHP settings is UTC, a string with another timezone,
e.g. 2015-04-24T21:11:00+02:00, will fail to be validated. The result from
the date()-function in this example is 2015-04-24T19:11:00+00:00, which is
a different string then the input.
The DateTime-class has also an option to create a string from a format,
DateTime->format(). So it is possible to skip the use of the
date()-function with the added benefit that using format() does have
access to the timezone information and thus produces the expected
2015-04-24T21:11:00+02:00 to compare with the given input.

This commit changes the Rule to accommodate this and expands the tests. If
these added tests are run before applying the fix to the Date-rule, the
tests will fail.
2015-04-24 23:03:45 +02:00
Henrique Moody d3a156f49e Create "AbstractSearcher" class
There are some other rules which could extend this class too, like Tld
and CountryCode, but was not changed in order to avoid code duplication
or API breaks.
2015-04-24 14:55:00 -03:00
Henrique Moody d728061c45 Create "Country" rule 2015-04-23 14:12:53 -03:00
Henrique Moody ec6eb82a00 Merge branch '0.8' 2015-04-17 00:04:02 -03:00
Henrique Moody 8ca24c2f84 Merge branch '0.7' into 0.8 2015-04-17 00:03:36 -03:00
Henrique Moody 0b6c5273e4 Fix wrong behaviour on Not rule 2015-04-16 23:45:17 -03:00
Henrique Moody 4ee11a7c19 Merge branch '0.8' 2015-04-16 14:02:47 -03:00
Henrique Moody f8fb86df45 Merge branch '0.7' into 0.8 2015-04-16 13:57:51 -03:00
Andreas Wolf 8ba31398fd Make AlwaysInvalid::assert('') fail
Resolves #326
2015-04-16 13:56:27 -03:00
Hugo Hamon 03114c3681 [Rules] simplified if/else conditions. 2015-03-28 12:43:27 +01:00
Henrique Moody 0b7b24a3cf Merge branch '0.8' 2015-03-02 14:06:36 -03:00
Henrique Moody c385684249 Merge branch '0.7' into 0.8 2015-03-02 14:05:46 -03:00
Henrique Moody acea4cd583 Update REGEX for postal code of "GB" country 2015-03-02 13:58:24 -03:00
Eduardo Gulias Davis 13c3c92ae6 Use "egulias/emailvalidator" for email validation 2015-03-01 21:10:30 -03:00
Henrique Moody fa67f0b030 Merge branch '0.8' 2015-02-20 10:37:13 -02:00
Henrique Moody 472be85d41 Merge branch '0.7' into 0.8 2015-02-20 10:36:47 -02:00
Henrique Moody ab8ba09b14 Fix wrong behavior on AbstractRelated class
The wrong behavior was that any key with `''` was considered as true
even when the validator was/had NotEmpty rule.
2015-02-20 10:27:36 -02:00
Henrique Moody db0f71575f Create "Age" rule
Also add a deprecation note in "MinimumAge" rule documentation.
2015-02-19 19:38:16 -02:00
Henrique Moody 378e114c33 Merge branch '0.7' into 0.8 2015-02-13 09:33:57 -02:00
Alexandre Gaigalas 1b1689bdea AbstractRelated is accepts '' as valid by default 2015-02-13 09:22:18 -02:00
Henrique Moody 2914eba595 Merge pull request #176 from henriquemoody/namespace
Allow to define custom rule's namespaces/prefixes.
2015-02-11 12:43:59 -02:00
Henrique Moody a4cb20810d Create a Factory to create rules
It also provide a way to define namespaces/prefixes to use the custom
rules on Respect\Validation.
2015-02-11 11:35:19 -02:00
Henrique Moody d6855c0722 Improve date and time handling on "Max" rule 2015-02-11 11:18:39 -02:00
Henrique Moody e91d0ef22e Improve date and time handling on "Min" rule 2015-02-11 11:18:39 -02:00
Henrique Moody 9a5f4302cb Create "AbstractInterval" class 2015-02-11 11:18:39 -02:00
Alexander Wühr f7fe245555 Make Roman rule internally use Regex rule 2015-02-11 12:46:48 +01:00
Henrique Moody 16e3eb9696 Merge pull request #288 from l-x/master
Optimize PrimeNumber rule
2015-02-06 14:51:24 -02:00
Alexander Wühr 8f372f878c Optimize PrimeNumber rule 2015-02-06 10:45:43 +01:00
Henrique Moody fd3fb80b8b Merge branch '0.7' 2015-02-05 14:40:20 -02:00
Henrique Moody 29d3fcc1bd Required improvements on "PostalCode" rule
- Turn rule case insensitive
- Use default pattern for countries who doesn't have postal code
2015-02-05 13:59:50 -02:00
Henrique Moody 4c4c3d4c25 Create "Type" rule 2015-02-02 16:43:14 -02:00
Andy Wendt ab65035181 Issue #260: Now using Respect\Validation exceptions only
* `ExceptionInterface`: all Respect\Validation\Exceptions implement through inheritance
* `ValidatorExceptionInterface`: implemented only by AllOfException.  This allows the end users to know when there has been a Validator exception rather than just any of our exceptions.

Fixed formatting issues

Created two new exception types

* Created ValidationExceptionInterface
* Created NestedValidationExceptionInterface which extends ValidationExceptionInterface
    * Renamed from ValidatorExceptionInterface

* ValidationException implements ValidationExceptionInterface and ValidationExceptionTest checks for the implementation.
* AbstractNestedException implements NestedValidationExceptionInterface and AbstractNestedExceptionTest checks for the implementation.

* CheckExceptionsTest now checks all Rule exceptions to make sure they implement ValidationExceptionInterface
* ValidatorTest now contains test that shows that only ValidationExceptionInterface can be used reliably with `::check()`

* Updated documentation for new exception types
* Reworked examples to show how to catch the exception interfaces

Minor changes in readme.md and ExceptionInterfaces

* Removed `import` statements (hahaha)
* Renamed `$e` to `$exception`

* `ValidationExceptionInterface` now extends `ExceptionInterface`.  Changed `ValidationException` to match
2015-01-31 07:59:59 -07:00
Henrique Moody 8c6390ed02 Update rules' documentations 2015-01-29 10:51:53 -02:00
Henrique Moody e20ddce185 Create "Url" rule 2015-01-27 10:43:00 -02:00
Henrique Moody a0e7e834fb Create "FilterVar" rule 2015-01-26 11:25:26 -02:00
kmilotxm@gmail.com ffda46fdea Fix the coding standards problems. 2015-01-23 15:52:19 -02:00
Camilo Teixeira de Melo 53e0f51220 Performance optimization in NumberPrime.php
Performance optimization and improvement in the algorithm NumberPrime.php
2015-01-23 15:09:01 -02:00
Henrique Moody 81cfba9a6c Merge pull request #247 from henriquemoody/when
Allow to use `when()` rule without else
2015-01-23 02:53:21 -02:00