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

Commit 869694b

Browse files
committed
feat: added LessThanOrEqual rule documentation
1 parent 51f8b03 commit 869694b

4 files changed

Lines changed: 60 additions & 6 deletions

File tree

docs/03-rules-greater-than-or-equal.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# GreaterThanOrEqual
22

3-
Validates that a value is greater than or equal to another value. Can compare between strings, numbers and dates.
3+
Validates that a value is greater than or equal to another value.
4+
Can compare between strings, numbers and dates.
45

56
## Basic Usage
67

@@ -28,7 +29,8 @@ Validator::greaterThan(new DateTime('today'))->validate(new DateTime('today'));
2829

2930
type: `mixed` `required`
3031

31-
It defines the comparison/minimum value. Can be a `string`, `int`, `float` or `DateTimeInterface` object.
32+
It defines the comparison/minimum value.
33+
Can be a `string`, `int`, `float` or `DateTimeInterface` object.
3234

3335
### `message`
3436

docs/03-rules-greater-than.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# GreaterThan
22

3-
Validates that a value is greater than another value. Can compare between strings, numbers and dates.
3+
Validates that a value is greater than another value.
4+
Can compare between strings, numbers and dates.
45

56
## Basic Usage
67

@@ -24,7 +25,8 @@ Validator::greaterThan(new DateTime('today'))->validate(new DateTime('tomorrow')
2425

2526
type: `mixed` `required`
2627

27-
It defines the comparison/minimum value. Can be a `string`, `int`, `float` or `DateTimeInterface` object.
28+
It defines the comparison/minimum value.
29+
Can be a `string`, `int`, `float` or `DateTimeInterface` object.
2830

2931
### `message`
3032

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

docs/03-rules-less-than.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# LessThan
22

3-
Validates that a value is less than another value. Can compare between strings, numbers and dates.
3+
Validates that a value is less than another value.
4+
Can compare between strings, numbers and dates.
45

56
## Basic Usage
67

@@ -24,7 +25,8 @@ Validator::greaterThan(new DateTime('today'))->validate(new DateTime('yesterday'
2425

2526
type: `mixed` `required`
2627

27-
It defines the comparison/maximum value. Can be a `string`, `int`, `float` or `DateTimeInterface` object.
28+
It defines the comparison/maximum value.
29+
Can be a `string`, `int`, `float` or `DateTimeInterface` object.
2830

2931
### `message`
3032

0 commit comments

Comments
 (0)