From b53d59f9e75f8b837319a13a9aecb90117e3da45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 8 Feb 2022 13:09:10 +0000 Subject: [PATCH 1/3] Added char validator --- src/Validator/Char.php | 126 +++++++++++++++++++++++++++++++++++ tests/Validator/CharTest.php | 87 ++++++++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 src/Validator/Char.php create mode 100755 tests/Validator/CharTest.php diff --git a/src/Validator/Char.php b/src/Validator/Char.php new file mode 100644 index 00000000..dbc110d6 --- /dev/null +++ b/src/Validator/Char.php @@ -0,0 +1,126 @@ + + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use Utopia\Validator; + +/** + * Text + * + * Validate that an variable is a valid text value + * + * @package Utopia\Validator + */ +class Char extends Validator +{ + const NUMBERS = [ '0','1','2','3','4','5','6','7','8','9' ]; + const ALPHABET_UPPER = [ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' ]; + const ALPHABET_LOWER = [ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' ]; + + /** + * @var int + */ + protected int $length = 0; + + /** + * @var string[] + */ + protected array $whitelist = []; + + /** + * Text constructor. + * + * Validate text with maximum length $length. Use $length = 0 for unlimited length + * + * @param int $length + * @param string[] $whitelist + */ + public function __construct(int $length, array $whitelist) + { + $this->length = $length; + $this->whitelist = $whitelist; + } + + /** + * Get Description + * + * Returns validator description + * + * @return string + */ + public function getDescription(): string + { + $message = 'Value must be a valid string'; + + if ($this->length) { + $message .= ' and no longer than ' . $this->length . ' chars'; + } + + if ($this->whitelist) { + $message .= ' and only consist of \'' . \join(', ', $this->whitelist) . '\' chars'; + } + + return $message; + } + + /** + * Is array + * + * Function will return true if object is array. + * + * @return bool + */ + public function isArray(): bool + { + return false; + } + + /** + * Get Type + * + * Returns validator type. + * + * @return string + */ + public function getType(): string + { + return self::TYPE_STRING; + } + + /** + * Is valid + * + * Validation will pass when $value is text with valid length. + * + * @param mixed $value + * @return bool + */ + public function isValid(mixed $value): bool + { + if (!\is_string($value)) { + return false; + } + + if (\mb_strlen($value) > $this->length && $this->length !== 0) { + return false; + } + + foreach (\str_split($value) as $char) { + if(!\in_array($char, $this->whitelist)) { + return false; + } + } + + return true; + } +} diff --git a/tests/Validator/CharTest.php b/tests/Validator/CharTest.php new file mode 100755 index 00000000..524acd71 --- /dev/null +++ b/tests/Validator/CharTest.php @@ -0,0 +1,87 @@ + + * @version 1.0 RC4 + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use PHPUnit\Framework\TestCase; + +class CharTest extends TestCase +{ + public function setUp():void + { + } + + public function tearDown():void + { + } + + public function testIsValid() + { + // Test lowercase alphabet + $this->validator = new Char(100, Char::ALPHABET_LOWER); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('qwertzuiopasdfghjklyxcvbnm')); + $this->assertEquals(true, $this->validator->isValid('hello')); + $this->assertEquals(true, $this->validator->isValid('world')); + $this->assertEquals(false, $this->validator->isValid('hello world')); + $this->assertEquals(false, $this->validator->isValid('Hello')); + $this->assertEquals(false, $this->validator->isValid('worlD')); + $this->assertEquals(false, $this->validator->isValid('hello123')); + + // Test uppercase alphabet + $this->validator = new Char(100, Char::ALPHABET_UPPER); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNM')); + $this->assertEquals(true, $this->validator->isValid('HELLO')); + $this->assertEquals(true, $this->validator->isValid('WORLD')); + $this->assertEquals(false, $this->validator->isValid('HELLO WORLD')); + $this->assertEquals(false, $this->validator->isValid('hELLO')); + $this->assertEquals(false, $this->validator->isValid('WORLd')); + $this->assertEquals(false, $this->validator->isValid('HELLO123')); + + // Test numbers + $this->validator = new Char(100, Char::NUMBERS); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('1234567890')); + $this->assertEquals(true, $this->validator->isValid('123')); + $this->assertEquals(false, $this->validator->isValid('123 456')); + $this->assertEquals(false, $this->validator->isValid('hello123')); + + // Test combination of whitelists + $this->validator = new Char(100, [ + ...Char::ALPHABET_LOWER, + ...Char::ALPHABET_UPPER, + ...Char::NUMBERS + ]); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('1234567890')); + $this->assertEquals(true, $this->validator->isValid('qwertzuiopasdfghjklyxcvbnm')); + $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNM')); + $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNMqwertzuiopasdfghjklyxcvbnm1234567890')); + $this->assertEquals(false, $this->validator->isValid('hello-world')); + $this->assertEquals(false, $this->validator->isValid('hello_world')); + $this->assertEquals(false, $this->validator->isValid('hello/world')); + + // Test length validation + $this->validator = new Char(5, Char::ALPHABET_LOWER); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('hell')); + $this->assertEquals(true, $this->validator->isValid('hello')); + $this->assertEquals(false, $this->validator->isValid('hellow')); + } +} From b76b2af40c653713bd7a1c87a53dd4ee467d9416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Feb 2022 10:32:59 +0000 Subject: [PATCH 2/3] Migrated Char to Text validator --- composer.lock | 332 +++++++++++++++++++++-------------- src/Validator/Char.php | 126 ------------- src/Validator/Text.php | 29 ++- tests/Validator/CharTest.php | 87 --------- tests/Validator/TextTest.php | 60 +++++++ 5 files changed, 291 insertions(+), 343 deletions(-) delete mode 100644 src/Validator/Char.php delete mode 100755 tests/Validator/CharTest.php diff --git a/composer.lock b/composer.lock index 6294b236..01fc5fe1 100644 --- a/composer.lock +++ b/composer.lock @@ -129,12 +129,12 @@ } }, "autoload": { - "psr-4": { - "Amp\\ByteStream\\": "lib" - }, "files": [ "lib/functions.php" - ] + ], + "psr-4": { + "Amp\\ByteStream\\": "lib" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -175,16 +175,16 @@ }, { "name": "composer/package-versions-deprecated", - "version": "1.11.99.4", + "version": "1.11.99.5", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "b174585d1fe49ceed21928a945138948cb394600" + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b174585d1fe49ceed21928a945138948cb394600", - "reference": "b174585d1fe49ceed21928a945138948cb394600", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b4f54f74ef3453349c24a845d22392cd31e65f1d", + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d", "shasum": "" }, "require": { @@ -228,7 +228,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.4" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.5" }, "funding": [ { @@ -244,27 +244,98 @@ "type": "tidelift" } ], - "time": "2021-09-13T08:41:34+00:00" + "time": "2022-01-17T14:14:24+00:00" + }, + { + "name": "composer/pcre", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/1.0.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-01-21T20:24:37+00:00" }, { "name": "composer/semver", - "version": "3.2.6", + "version": "3.2.9", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "83e511e247de329283478496f7a1e114c9517506" + "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/83e511e247de329283478496f7a1e114c9517506", - "reference": "83e511e247de329283478496f7a1e114c9517506", + "url": "https://api.github.com/repos/composer/semver/zipball/a951f614bd64dcd26137bc9b7b2637ddcfc57649", + "reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.54", + "phpstan/phpstan": "^1.4", "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", @@ -309,7 +380,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.2.6" + "source": "https://github.com/composer/semver/tree/3.2.9" }, "funding": [ { @@ -325,29 +396,31 @@ "type": "tidelift" } ], - "time": "2021-10-25T11:34:17+00:00" + "time": "2022-02-04T13:58:43+00:00" }, { "name": "composer/xdebug-handler", - "version": "2.0.2", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339" + "reference": "0c1a3925ec58a4ec98e992b9c7d171e9e184be0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339", - "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/0c1a3925ec58a4ec98e992b9c7d171e9e184be0a", + "reference": "0c1a3925ec58a4ec98e992b9c7d171e9e184be0a", "shasum": "" }, "require": { + "composer/pcre": "^1", "php": "^5.3.2 || ^7.0 || ^8.0", "psr/log": "^1 || ^2 || ^3" }, "require-dev": { - "phpstan/phpstan": "^0.12.55", - "symfony/phpunit-bridge": "^4.2 || ^5" + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0" }, "type": "library", "autoload": { @@ -373,7 +446,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/2.0.2" + "source": "https://github.com/composer/xdebug-handler/tree/2.0.4" }, "funding": [ { @@ -389,7 +462,7 @@ "type": "tidelift" } ], - "time": "2021-07-31T17:03:58+00:00" + "time": "2022-01-04T17:06:45+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -615,9 +688,6 @@ "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" - }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -625,12 +695,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -709,16 +779,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.13.1", + "version": "v4.13.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd" + "reference": "210577fe3cf7badcc5814d99455df46564f3c077" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd", - "reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", + "reference": "210577fe3cf7badcc5814d99455df46564f3c077", "shasum": "" }, "require": { @@ -759,9 +829,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" }, - "time": "2021-11-03T20:52:16+00:00" + "time": "2021-11-30T19:35:32+00:00" }, { "name": "openlss/lib-array2xml", @@ -878,16 +948,16 @@ }, { "name": "phar-io/version", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "bae7c545bef187884426f042434e561ab1ddb182" + "reference": "15a90844ad40f127afd244c0cad228de2a80052a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", - "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "url": "https://api.github.com/repos/phar-io/version/zipball/15a90844ad40f127afd244c0cad228de2a80052a", + "reference": "15a90844ad40f127afd244c0cad228de2a80052a", "shasum": "" }, "require": { @@ -923,9 +993,9 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.0" + "source": "https://github.com/phar-io/version/tree/3.1.1" }, - "time": "2021-02-23T14:00:09+00:00" + "time": "2022-02-07T21:56:48+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -1039,16 +1109,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.5.1", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae" + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/a12f7e301eb7258bb68acd89d4aefa05c2906cae", - "reference": "a12f7e301eb7258bb68acd89d4aefa05c2906cae", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", "shasum": "" }, "require": { @@ -1083,22 +1153,22 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.5.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" }, - "time": "2021-10-02T14:08:47+00:00" + "time": "2022-01-04T19:58:01+00:00" }, { "name": "phpspec/prophecy", - "version": "1.14.0", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" + "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", - "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", + "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", "shasum": "" }, "require": { @@ -1150,22 +1220,22 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.14.0" + "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" }, - "time": "2021-09-10T09:02:12+00:00" + "time": "2021-12-08T12:19:24+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.9", + "version": "9.2.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b" + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", - "reference": "f301eb1453c9e7a1bc912ee8b0ea9db22c60223b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", + "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", "shasum": "" }, "require": { @@ -1221,7 +1291,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.9" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" }, "funding": [ { @@ -1229,20 +1299,20 @@ "type": "github" } ], - "time": "2021-11-19T15:21:02+00:00" + "time": "2021-12-05T09:12:13+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.5", + "version": "3.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", - "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { @@ -1281,7 +1351,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, "funding": [ { @@ -1289,7 +1359,7 @@ "type": "github" } ], - "time": "2020-09-28T05:57:25+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { "name": "phpunit/php-invoker", @@ -1474,16 +1544,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.10", + "version": "9.5.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a" + "reference": "597cb647654ede35e43b137926dfdfef0fb11743" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c814a05837f2edb0d1471d6e3f4ab3501ca3899a", - "reference": "c814a05837f2edb0d1471d6e3f4ab3501ca3899a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/597cb647654ede35e43b137926dfdfef0fb11743", + "reference": "597cb647654ede35e43b137926dfdfef0fb11743", "shasum": "" }, "require": { @@ -1534,11 +1604,11 @@ } }, "autoload": { - "classmap": [ - "src/" - ], "files": [ "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1561,11 +1631,11 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.13" }, "funding": [ { - "url": "https://phpunit.de/donate.html", + "url": "https://phpunit.de/sponsors.html", "type": "custom" }, { @@ -1573,7 +1643,7 @@ "type": "github" } ], - "time": "2021-09-25T07:38:51+00:00" + "time": "2022-01-24T07:33:35+00:00" }, { "name": "psr/container", @@ -2184,16 +2254,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.3", + "version": "5.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + "reference": "19c519631c5a511b7ed0ad64a6713fdb3fd25fe4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/19c519631c5a511b7ed0ad64a6713fdb3fd25fe4", + "reference": "19c519631c5a511b7ed0ad64a6713fdb3fd25fe4", "shasum": "" }, "require": { @@ -2236,7 +2306,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.4" }, "funding": [ { @@ -2244,7 +2314,7 @@ "type": "github" } ], - "time": "2021-06-11T13:31:12+00:00" + "time": "2022-02-10T07:01:19+00:00" }, { "name": "sebastian/lines-of-code", @@ -2644,16 +2714,16 @@ }, { "name": "symfony/console", - "version": "v6.0.0", + "version": "v6.0.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "675a4e6b05029a02ac43d3daf5aa73f039e876ea" + "reference": "22e8efd019c3270c4f79376234a3f8752cd25490" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/675a4e6b05029a02ac43d3daf5aa73f039e876ea", - "reference": "675a4e6b05029a02ac43d3daf5aa73f039e876ea", + "url": "https://api.github.com/repos/symfony/console/zipball/22e8efd019c3270c4f79376234a3f8752cd25490", + "reference": "22e8efd019c3270c4f79376234a3f8752cd25490", "shasum": "" }, "require": { @@ -2719,7 +2789,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.0.0" + "source": "https://github.com/symfony/console/tree/v6.0.3" }, "funding": [ { @@ -2735,25 +2805,28 @@ "type": "tidelift" } ], - "time": "2021-11-29T15:32:57+00:00" + "time": "2022-01-26T17:23:29+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + "reference": "30885182c981ab175d4d034db0f6f469898070ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-ctype": "*" + }, "suggest": { "ext-ctype": "For best performance" }, @@ -2798,7 +2871,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" }, "funding": [ { @@ -2814,20 +2887,20 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-10-20T20:35:02+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.23.1", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", "shasum": "" }, "require": { @@ -2847,12 +2920,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2879,7 +2952,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0" }, "funding": [ { @@ -2895,11 +2968,11 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2021-11-23T21:10:46+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -2928,12 +3001,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -2963,7 +3036,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0" }, "funding": [ { @@ -2983,21 +3056,24 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.23.1", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-mbstring": "*" + }, "suggest": { "ext-mbstring": "For best performance" }, @@ -3043,7 +3119,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" }, "funding": [ { @@ -3059,7 +3135,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:26:48+00:00" + "time": "2021-11-30T18:21:41+00:00" }, { "name": "symfony/service-contracts", @@ -3145,16 +3221,16 @@ }, { "name": "symfony/string", - "version": "v6.0.0", + "version": "v6.0.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "ba727797426af0f587f4800566300bdc0cda0777" + "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ba727797426af0f587f4800566300bdc0cda0777", - "reference": "ba727797426af0f587f4800566300bdc0cda0777", + "url": "https://api.github.com/repos/symfony/string/zipball/522144f0c4c004c80d56fa47e40e17028e2eefc2", + "reference": "522144f0c4c004c80d56fa47e40e17028e2eefc2", "shasum": "" }, "require": { @@ -3210,7 +3286,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.0.0" + "source": "https://github.com/symfony/string/tree/v6.0.3" }, "funding": [ { @@ -3226,7 +3302,7 @@ "type": "tidelift" } ], - "time": "2021-10-29T07:35:21+00:00" + "time": "2022-01-02T09:55:41+00:00" }, { "name": "theseer/tokenizer", @@ -3355,13 +3431,13 @@ } }, "autoload": { - "psr-4": { - "Psalm\\": "src/Psalm/" - }, "files": [ "src/functions.php", "src/spl_object_id.php" - ] + ], + "psr-4": { + "Psalm\\": "src/Psalm/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3503,5 +3579,5 @@ "php": ">=8.0.0" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Validator/Char.php b/src/Validator/Char.php deleted file mode 100644 index dbc110d6..00000000 --- a/src/Validator/Char.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @license The MIT License (MIT) - */ - -namespace Utopia\Validator; - -use Utopia\Validator; - -/** - * Text - * - * Validate that an variable is a valid text value - * - * @package Utopia\Validator - */ -class Char extends Validator -{ - const NUMBERS = [ '0','1','2','3','4','5','6','7','8','9' ]; - const ALPHABET_UPPER = [ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' ]; - const ALPHABET_LOWER = [ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' ]; - - /** - * @var int - */ - protected int $length = 0; - - /** - * @var string[] - */ - protected array $whitelist = []; - - /** - * Text constructor. - * - * Validate text with maximum length $length. Use $length = 0 for unlimited length - * - * @param int $length - * @param string[] $whitelist - */ - public function __construct(int $length, array $whitelist) - { - $this->length = $length; - $this->whitelist = $whitelist; - } - - /** - * Get Description - * - * Returns validator description - * - * @return string - */ - public function getDescription(): string - { - $message = 'Value must be a valid string'; - - if ($this->length) { - $message .= ' and no longer than ' . $this->length . ' chars'; - } - - if ($this->whitelist) { - $message .= ' and only consist of \'' . \join(', ', $this->whitelist) . '\' chars'; - } - - return $message; - } - - /** - * Is array - * - * Function will return true if object is array. - * - * @return bool - */ - public function isArray(): bool - { - return false; - } - - /** - * Get Type - * - * Returns validator type. - * - * @return string - */ - public function getType(): string - { - return self::TYPE_STRING; - } - - /** - * Is valid - * - * Validation will pass when $value is text with valid length. - * - * @param mixed $value - * @return bool - */ - public function isValid(mixed $value): bool - { - if (!\is_string($value)) { - return false; - } - - if (\mb_strlen($value) > $this->length && $this->length !== 0) { - return false; - } - - foreach (\str_split($value) as $char) { - if(!\in_array($char, $this->whitelist)) { - return false; - } - } - - return true; - } -} diff --git a/src/Validator/Text.php b/src/Validator/Text.php index b27c79d5..8087e59f 100644 --- a/src/Validator/Text.php +++ b/src/Validator/Text.php @@ -23,21 +23,33 @@ */ class Text extends Validator { + const NUMBERS = [ '0','1','2','3','4','5','6','7','8','9' ]; + const ALPHABET_UPPER = [ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' ]; + const ALPHABET_LOWER = [ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' ]; + /** * @var int */ protected int $length = 0; + /** + * @var string[] + */ + protected array $whitelist = []; + /** * Text constructor. * - * Validate text with maximum length $length. Use $length = 0 for unlimited length + * Validate text with maximum length $length. Use $length = 0 for unlimited length. + * Optionally, provide whitelist characters array $whitelist to only allow specific character. * * @param int $length + * @param string[] $whitelist */ - public function __construct(int $length) + public function __construct(int $length, array $whitelist = []) { $this->length = $length; + $this->whitelist = $whitelist; } /** @@ -54,6 +66,11 @@ public function getDescription(): string if ($this->length) { $message .= ' and no longer than ' . $this->length . ' chars'; } + + if ($this->whitelist) { + $message .= ' and only consist of \'' . \join(', ', $this->whitelist) . '\' chars'; + } + return $message; } @@ -99,6 +116,14 @@ public function isValid(mixed $value): bool return false; } + if(\count($this->whitelist) > 0) { + foreach (\str_split($value) as $char) { + if(!\in_array($char, $this->whitelist)) { + return false; + } + } + } + return true; } } diff --git a/tests/Validator/CharTest.php b/tests/Validator/CharTest.php deleted file mode 100755 index 524acd71..00000000 --- a/tests/Validator/CharTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @version 1.0 RC4 - * @license The MIT License (MIT) - */ - -namespace Utopia\Validator; - -use PHPUnit\Framework\TestCase; - -class CharTest extends TestCase -{ - public function setUp():void - { - } - - public function tearDown():void - { - } - - public function testIsValid() - { - // Test lowercase alphabet - $this->validator = new Char(100, Char::ALPHABET_LOWER); - $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); - $this->assertEquals(false, $this->validator->isArray()); - $this->assertEquals(true, $this->validator->isValid('qwertzuiopasdfghjklyxcvbnm')); - $this->assertEquals(true, $this->validator->isValid('hello')); - $this->assertEquals(true, $this->validator->isValid('world')); - $this->assertEquals(false, $this->validator->isValid('hello world')); - $this->assertEquals(false, $this->validator->isValid('Hello')); - $this->assertEquals(false, $this->validator->isValid('worlD')); - $this->assertEquals(false, $this->validator->isValid('hello123')); - - // Test uppercase alphabet - $this->validator = new Char(100, Char::ALPHABET_UPPER); - $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); - $this->assertEquals(false, $this->validator->isArray()); - $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNM')); - $this->assertEquals(true, $this->validator->isValid('HELLO')); - $this->assertEquals(true, $this->validator->isValid('WORLD')); - $this->assertEquals(false, $this->validator->isValid('HELLO WORLD')); - $this->assertEquals(false, $this->validator->isValid('hELLO')); - $this->assertEquals(false, $this->validator->isValid('WORLd')); - $this->assertEquals(false, $this->validator->isValid('HELLO123')); - - // Test numbers - $this->validator = new Char(100, Char::NUMBERS); - $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); - $this->assertEquals(false, $this->validator->isArray()); - $this->assertEquals(true, $this->validator->isValid('1234567890')); - $this->assertEquals(true, $this->validator->isValid('123')); - $this->assertEquals(false, $this->validator->isValid('123 456')); - $this->assertEquals(false, $this->validator->isValid('hello123')); - - // Test combination of whitelists - $this->validator = new Char(100, [ - ...Char::ALPHABET_LOWER, - ...Char::ALPHABET_UPPER, - ...Char::NUMBERS - ]); - $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); - $this->assertEquals(false, $this->validator->isArray()); - $this->assertEquals(true, $this->validator->isValid('1234567890')); - $this->assertEquals(true, $this->validator->isValid('qwertzuiopasdfghjklyxcvbnm')); - $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNM')); - $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNMqwertzuiopasdfghjklyxcvbnm1234567890')); - $this->assertEquals(false, $this->validator->isValid('hello-world')); - $this->assertEquals(false, $this->validator->isValid('hello_world')); - $this->assertEquals(false, $this->validator->isValid('hello/world')); - - // Test length validation - $this->validator = new Char(5, Char::ALPHABET_LOWER); - $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); - $this->assertEquals(false, $this->validator->isArray()); - $this->assertEquals(true, $this->validator->isValid('hell')); - $this->assertEquals(true, $this->validator->isValid('hello')); - $this->assertEquals(false, $this->validator->isValid('hellow')); - } -} diff --git a/tests/Validator/TextTest.php b/tests/Validator/TextTest.php index f99dbaa8..c64cc54b 100755 --- a/tests/Validator/TextTest.php +++ b/tests/Validator/TextTest.php @@ -45,4 +45,64 @@ public function testIsValid() $this->assertEquals(false, $this->text->isArray()); $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->text->getType()); } + + public function testWhitelist() + { + // Test lowercase alphabet + $this->validator = new Text(100, Text::ALPHABET_LOWER); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('qwertzuiopasdfghjklyxcvbnm')); + $this->assertEquals(true, $this->validator->isValid('hello')); + $this->assertEquals(true, $this->validator->isValid('world')); + $this->assertEquals(false, $this->validator->isValid('hello world')); + $this->assertEquals(false, $this->validator->isValid('Hello')); + $this->assertEquals(false, $this->validator->isValid('worlD')); + $this->assertEquals(false, $this->validator->isValid('hello123')); + + // Test uppercase alphabet + $this->validator = new Text(100, Text::ALPHABET_UPPER); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNM')); + $this->assertEquals(true, $this->validator->isValid('HELLO')); + $this->assertEquals(true, $this->validator->isValid('WORLD')); + $this->assertEquals(false, $this->validator->isValid('HELLO WORLD')); + $this->assertEquals(false, $this->validator->isValid('hELLO')); + $this->assertEquals(false, $this->validator->isValid('WORLd')); + $this->assertEquals(false, $this->validator->isValid('HELLO123')); + + // Test numbers + $this->validator = new Text(100, Text::NUMBERS); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('1234567890')); + $this->assertEquals(true, $this->validator->isValid('123')); + $this->assertEquals(false, $this->validator->isValid('123 456')); + $this->assertEquals(false, $this->validator->isValid('hello123')); + + // Test combination of whitelists + $this->validator = new Text(100, [ + ...Text::ALPHABET_LOWER, + ...Text::ALPHABET_UPPER, + ...Text::NUMBERS + ]); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('1234567890')); + $this->assertEquals(true, $this->validator->isValid('qwertzuiopasdfghjklyxcvbnm')); + $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNM')); + $this->assertEquals(true, $this->validator->isValid('QWERTZUIOPASDFGHJKLYXCVBNMqwertzuiopasdfghjklyxcvbnm1234567890')); + $this->assertEquals(false, $this->validator->isValid('hello-world')); + $this->assertEquals(false, $this->validator->isValid('hello_world')); + $this->assertEquals(false, $this->validator->isValid('hello/world')); + + // Test length validation + $this->validator = new Text(5, Text::ALPHABET_LOWER); + $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->validator->getType()); + $this->assertEquals(false, $this->validator->isArray()); + $this->assertEquals(true, $this->validator->isValid('hell')); + $this->assertEquals(true, $this->validator->isValid('hello')); + $this->assertEquals(false, $this->validator->isValid('hellow')); + } } From 2abd583f31fa9445272d5aa9a35415995debe5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Feb 2022 14:50:22 +0000 Subject: [PATCH 3/3] Switched to new terminology --- src/Validator/Text.php | 18 +++++++++--------- tests/Validator/TextTest.php | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Validator/Text.php b/src/Validator/Text.php index 8087e59f..213609b3 100644 --- a/src/Validator/Text.php +++ b/src/Validator/Text.php @@ -35,21 +35,21 @@ class Text extends Validator /** * @var string[] */ - protected array $whitelist = []; + protected array $allowList = []; /** * Text constructor. * * Validate text with maximum length $length. Use $length = 0 for unlimited length. - * Optionally, provide whitelist characters array $whitelist to only allow specific character. + * Optionally, provide allowList characters array $allowList to only allow specific character. * * @param int $length - * @param string[] $whitelist + * @param string[] $allowList */ - public function __construct(int $length, array $whitelist = []) + public function __construct(int $length, array $allowList = []) { $this->length = $length; - $this->whitelist = $whitelist; + $this->allowList = $allowList; } /** @@ -67,8 +67,8 @@ public function getDescription(): string $message .= ' and no longer than ' . $this->length . ' chars'; } - if ($this->whitelist) { - $message .= ' and only consist of \'' . \join(', ', $this->whitelist) . '\' chars'; + if ($this->allowList) { + $message .= ' and only consist of \'' . \join(', ', $this->allowList) . '\' chars'; } return $message; @@ -116,9 +116,9 @@ public function isValid(mixed $value): bool return false; } - if(\count($this->whitelist) > 0) { + if(\count($this->allowList) > 0) { foreach (\str_split($value) as $char) { - if(!\in_array($char, $this->whitelist)) { + if(!\in_array($char, $this->allowList)) { return false; } } diff --git a/tests/Validator/TextTest.php b/tests/Validator/TextTest.php index c64cc54b..72c3106d 100755 --- a/tests/Validator/TextTest.php +++ b/tests/Validator/TextTest.php @@ -46,7 +46,7 @@ public function testIsValid() $this->assertEquals(\Utopia\Validator::TYPE_STRING, $this->text->getType()); } - public function testWhitelist() + public function testAllowList() { // Test lowercase alphabet $this->validator = new Text(100, Text::ALPHABET_LOWER); @@ -81,7 +81,7 @@ public function testWhitelist() $this->assertEquals(false, $this->validator->isValid('123 456')); $this->assertEquals(false, $this->validator->isValid('hello123')); - // Test combination of whitelists + // Test combination of allowLists $this->validator = new Text(100, [ ...Text::ALPHABET_LOWER, ...Text::ALPHABET_UPPER,