Skip to content

Commit a29c8a6

Browse files
authored
Merge pull request #11 from MaplePHP/develop
v1.2.0
2 parents dd844bc + 0f20fde commit a29c8a6

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

Inp.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,59 @@ public function equal($str): bool
492492
return ($this->value === $str);
493493
}
494494

495+
/**
496+
* IF value is less than to parameter
497+
* @param $num
498+
* @return bool
499+
*/
500+
public function lessThan($num): bool
501+
{
502+
return ($this->value < (float)$num);
503+
}
504+
505+
/**
506+
* IF value is more than to parameter
507+
* @param $num
508+
* @return bool
509+
*/
510+
public function moreThan($num): bool
511+
{
512+
return ($this->value > (float)$num);
513+
}
514+
515+
/**
516+
* Checks if a string contains a given substring
517+
*
518+
* @param string $needle
519+
* @return bool
520+
*/
521+
public function contains(string $needle): bool
522+
{
523+
return str_contains($this->value, $needle);
524+
}
525+
526+
/**
527+
* Checks if a string starts with a given substring
528+
*
529+
* @param string $needle
530+
* @return bool
531+
*/
532+
public function startsWith(string $needle): bool
533+
{
534+
return str_starts_with($this->value, $needle);
535+
}
536+
537+
/**
538+
* Checks if a string ends with a given substring
539+
*
540+
* @param string $needle
541+
* @return bool
542+
*/
543+
public function endsWith(string $needle): bool
544+
{
545+
return str_ends_with($this->value, $needle);
546+
}
547+
495548
/**
496549
* IF value equals to param
497550
* @param $str

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ Inp::value("Lorem ipsum dolor")->equal("Lorem ipsum dolor");
5757
```php
5858
Inp::value("Lorem ipsum dolor")->notEqual("Lorem ipsum");
5959
```
60+
- **More than**:
61+
```php
62+
Inp::value(200)->moreThan(100);
63+
```
64+
- **Less than**:
65+
```php
66+
Inp::value(100)->lessThan(200);
67+
```
68+
- **Contains**:
69+
```php
70+
Inp::value("Lorem ipsum dolor")->contains("ipsum");
71+
```
72+
- **Starts with**:
73+
```php
74+
Inp::value("Lorem ipsum dolor")->startsWith("Lorem");
75+
```
76+
- **Ends with**:
77+
```php
78+
Inp::value("Lorem ipsum dolor")->endsWith("dolor");
79+
```
6080

6181
### Validate if it's a valid email
6282
```php

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "maplephp/validate",
33
"type": "library",
4-
"version": "v1.1.0",
4+
"version": "v1.2.0",
55
"description": "User-friendly input validation library.",
66
"keywords": [
77
"validation",

0 commit comments

Comments
 (0)