Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 8d20093

Browse files
committed
feat: added GreaterThanOrEqual rule documentation
1 parent 2d0a49a commit 8d20093

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# GreaterThanOrEqual
2+
3+
Validates that a value is greater than or equal to another value. Can compare between strings, numbers and dates.
4+
5+
## Basic Usage
6+
7+
```php
8+
Validator::greaterThan(10)->validate(20); // true
9+
Validator::greaterThan(10)->validate(10); // true
10+
Validator::greaterThan(1.5)->validate(2.5); // true
11+
Validator::greaterThan(1.5)->validate(1.5); // true
12+
Validator::greaterThan('alpha')->validate('beta'); // true
13+
Validator::greaterThan('alpha')->validate('alpha'); // true
14+
Validator::greaterThan(new DateTime('today'))->validate(new DateTime('tomorrow')); // true
15+
Validator::greaterThan(new DateTime('today'))->validate(new DateTime('today')); // true
16+
```
17+
18+
> **Note**
19+
> String comparison is case-sensitive, meaning that comparing `'hello'` with `'Hello'` is different.
20+
> Check [`strcmp`](https://www.php.net/manual/en/function.strcmp.php) for more information.
21+
22+
> **Note**
23+
> An `UnexpectedValueException` will be thrown when trying to compare incomparable values, like a `string` with an `int`.
24+
25+
## Options
26+
27+
### `constraint`
28+
29+
type: `mixed` `required`
30+
31+
It defines the comparison/minimum value. Can be a `string`, `int`, `float` or `DateTimeInterface` object.
32+
33+
### `message`
34+
35+
type: `string` default: `The "{{ name }}" value should be greater than or equal to "{{ constraint }}", "{{ value }}" given.`
36+
37+
Message that will be shown if the value is not greater than or equal to the constraint value.
38+
Check the [Custom Messages]() section for more information.
39+
40+
The following parameters are available:
41+
42+
| Parameter | Description |
43+
|--------------------|------------------------------------|
44+
| `{{ value }}` | The current invalid value |
45+
| `{{ name }}` | Name of the value being validated |
46+
| `{{ constraint }}` | The comparison/minimum value |

docs/03-rules-greater-than.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ It defines the comparison/minimum value. Can be a `string`, `int`, `float` or `D
3030

3131
type: `string` default: `The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given.`
3232

33-
Message that will be shown if the value is not greater than the constraint value. Check the [Custom Messages]() section for more information.
33+
Message that will be shown if the value is not greater than the constraint value.
34+
Check the [Custom Messages]() section for more information.
3435

3536
The following parameters are available:
3637

docs/03-rules-not-blank.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Validator::notBlank(normalizer: fn($value) => trim($value))->validate(' '); // f
3636

3737
type: `string` default: `The "{{ name }}" value should not be blank, "{{ value }}" given.`
3838

39-
Message that will be shown if the value is blank. Check the [Custom Messages]() section for more information.
39+
Message that will be shown if the value is blank.
40+
Check the [Custom Messages]() section for more information.
4041

4142
The following parameters are available:
4243

0 commit comments

Comments
 (0)