Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Inp.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,59 @@ 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
*
* @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
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ 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");
```
- **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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down