diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 46d68d2..4c35c51 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -11,19 +11,16 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 10
- strategy:
- fail-fast: true
-
- name: PHP 8.1
+ name: PHP 8.3
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: 8.1
+ php-version: 8.3
tools: composer
coverage: xdebug
@@ -63,14 +60,11 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 10
- strategy:
- fail-fast: true
-
name: PHP Latest
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0e317ac..79714d2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,5 @@
---
-image: registry.gitlab.com/aplus-framework/images/base:2
+image: registry.gitlab.com/aplus-framework/images/base:4
include:
- template: Security/SAST.gitlab-ci.yml
diff --git a/composer.json b/composer.json
index b45eed9..7431d7c 100644
--- a/composer.json
+++ b/composer.json
@@ -30,13 +30,13 @@
}
],
"require": {
- "php": ">=8.1",
+ "php": ">=8.3",
"ext-fileinfo": "*",
"ext-intl": "*",
"ext-json": "*",
- "aplus/debug": "^3.1",
- "aplus/helpers": "^3.0",
- "aplus/language": "^3.0"
+ "aplus/debug": "^4.0",
+ "aplus/helpers": "^4.0",
+ "aplus/language": "^4.0"
},
"require-dev": {
"ext-xdebug": "*",
diff --git a/docker-compose.yml b/docker-compose.yml
index 7d3d85e..a6a5416 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,7 +1,7 @@
version: "3"
services:
package:
- image: registry.gitlab.com/aplus-framework/images/package:2
+ image: registry.gitlab.com/aplus-framework/images/package:4
container_name: package-validation
working_dir: /package
volumes:
diff --git a/guide/index.rst b/guide/index.rst
index 86bc365..ae5aa9e 100644
--- a/guide/index.rst
+++ b/guide/index.rst
@@ -51,7 +51,7 @@ Validation logic typically occurs as follows:
echo '';
}
-First load the Validation class. Then the rules are drafted and finally validated.
+First load the Validation class. Then the rules are set and finally validated.
Then a response is shown if the validation was valid or not.
Setting Rules
@@ -798,7 +798,7 @@ The field requires special characters.
The rule can take two parameters:: ``$quantity`` and ``$characters``.
-``$quantity`` x is the number and special characters the field value must have.
+``$quantity`` is the number of special characters the field value must have.
By default the value is ``1``.
``$characters`` are the characters considered special. By default they are these:
diff --git a/src/Debug/ValidationCollection.php b/src/Debug/ValidationCollection.php
new file mode 100644
index 0000000..066def8
--- /dev/null
+++ b/src/Debug/ValidationCollection.php
@@ -0,0 +1,22 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace Framework\Validation\Debug;
+
+use Framework\Debug\Collection;
+
+/**
+ * Class ValidationCollection.
+ *
+ * @package validation
+ */
+class ValidationCollection extends Collection
+{
+ protected string $iconPath = __DIR__ . '/icons/validation.svg';
+}
diff --git a/src/Debug/icons/validation.svg b/src/Debug/icons/validation.svg
new file mode 100644
index 0000000..e7420ee
--- /dev/null
+++ b/src/Debug/icons/validation.svg
@@ -0,0 +1 @@
+
diff --git a/src/Validation.php b/src/Validation.php
index db565fd..6411863 100644
--- a/src/Validation.php
+++ b/src/Validation.php
@@ -376,6 +376,16 @@ public function setError(string $field, string $rule, array $args = []) : static
return $this;
}
+ /**
+ * @param string $field
+ *
+ * @return bool
+ */
+ public function hasError(string $field) : bool
+ {
+ return isset($this->errors[$field]);
+ }
+
/**
* Set a custom error message for a field rule.
*
diff --git a/src/Validator.php b/src/Validator.php
index 482e6b3..57c373b 100644
--- a/src/Validator.php
+++ b/src/Validator.php
@@ -412,12 +412,7 @@ public static function datetime(
if ($datetime->format($format) !== $data) {
return false;
}
- $lastErrors = \DateTime::getLastErrors();
- if ($lastErrors === false) {
- return true;
- }
- return $lastErrors['warning_count'] === 0
- && $lastErrors['error_count'] === 0;
+ return \DateTime::getLastErrors() === false;
}
/**
diff --git a/tests/Debug/ValidationCollectionTest.php b/tests/Debug/ValidationCollectionTest.php
new file mode 100644
index 0000000..e78e3d0
--- /dev/null
+++ b/tests/Debug/ValidationCollectionTest.php
@@ -0,0 +1,28 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace Tests\Validation\Debug;
+
+use Framework\Validation\Debug\ValidationCollection;
+use PHPUnit\Framework\TestCase;
+
+final class ValidationCollectionTest extends TestCase
+{
+ protected ValidationCollection $collection;
+
+ protected function setUp() : void
+ {
+ $this->collection = new ValidationCollection('Validation');
+ }
+
+ public function testIcon() : void
+ {
+ self::assertStringStartsWith('