From c40a0e2d9450400b737a1bd829ea54ea0502b9eb Mon Sep 17 00:00:00 2001 From: Daniel Ronkainen Date: Sun, 16 Mar 2025 14:44:11 +0100 Subject: [PATCH 1/3] Add string find validations --- Inp.php | 33 +++++++++++++++++++++++++++++++++ README.md | 12 ++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Inp.php b/Inp.php index e6a06bf..0cd11f5 100755 --- a/Inp.php +++ b/Inp.php @@ -492,6 +492,39 @@ public function equal($str): bool return ($this->value === $str); } + /** + * Checks if a string contains a given substring + * + * @param string $needle + * @return bool + */ + public function contains(string $needle): bool + { + return str_contains($this->value, $needle); + } + + /** + * Checks if a string starts with a given substring + * + * @param string $needle + * @return bool + */ + public function startsWith(string $needle): bool + { + return str_starts_with($this->value, $needle); + } + + /** + * Checks if a string ends with a given substring + * + * @param string $needle + * @return bool + */ + public function endsWith(string $needle): bool + { + return str_ends_with($this->value, $needle); + } + /** * IF value equals to param * @param $str diff --git a/README.md b/README.md index 9b67bb5..2a40e5b 100755 --- a/README.md +++ b/README.md @@ -57,6 +57,18 @@ Inp::value("Lorem ipsum dolor")->equal("Lorem ipsum dolor"); ```php Inp::value("Lorem ipsum dolor")->notEqual("Lorem ipsum"); ``` +- **Contains**: +```php +Inp::value("Lorem ipsum dolor")->contains("ipsum"); +``` +- **Starts with**: +```php +Inp::value("Lorem ipsum dolor")->startsWith("Lorem"); +``` +- **Ends with**: +```php +Inp::value("Lorem ipsum dolor")->endsWith("dolor"); +``` ### Validate if it's a valid email ```php From f56d3466164aa5783d6c7212940c79e63e6af5c6 Mon Sep 17 00:00:00 2001 From: Daniel Ronkainen Date: Mon, 24 Mar 2025 21:39:10 +0100 Subject: [PATCH 2/3] Add less than and more than validations --- Inp.php | 20 ++++++++++++++++++++ README.md | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/Inp.php b/Inp.php index 0cd11f5..c685d73 100755 --- a/Inp.php +++ b/Inp.php @@ -492,6 +492,26 @@ public function equal($str): bool return ($this->value === $str); } + /** + * IF value is less than to parameter + * @param $num + * @return bool + */ + public function lessThan($num): bool + { + return ($this->value < (float)$num); + } + + /** + * IF value is more than to parameter + * @param $num + * @return bool + */ + public function moreThan($num): bool + { + return ($this->value > (float)$num); + } + /** * Checks if a string contains a given substring * diff --git a/README.md b/README.md index 2a40e5b..4e1834c 100755 --- a/README.md +++ b/README.md @@ -57,6 +57,14 @@ Inp::value("Lorem ipsum dolor")->equal("Lorem ipsum dolor"); ```php Inp::value("Lorem ipsum dolor")->notEqual("Lorem ipsum"); ``` +- **More than**: +```php +Inp::value(200)->moreThan(100); +``` +- **Less than**: +```php +Inp::value(100)->lessThan(200); +``` - **Contains**: ```php Inp::value("Lorem ipsum dolor")->contains("ipsum"); From 0f20fdecd4735677ec2f18ef3fb78e5619eca3fe Mon Sep 17 00:00:00 2001 From: Daniel Ronkainen Date: Mon, 24 Mar 2025 21:39:51 +0100 Subject: [PATCH 3/3] Bump version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 041a7a4..44cca68 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "maplephp/validate", "type": "library", - "version": "v1.1.0", + "version": "v1.2.0", "description": "User-friendly input validation library.", "keywords": [ "validation",