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

Commit 51f8b03

Browse files
committed
feat: added LessThan rule documentation
1 parent 8d20093 commit 51f8b03

3 files changed

Lines changed: 52 additions & 10 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Check the [Custom Messages]() section for more information.
3939

4040
The following parameters are available:
4141

42-
| Parameter | Description |
43-
|--------------------|------------------------------------|
44-
| `{{ value }}` | The current invalid value |
45-
| `{{ name }}` | Name of the value being validated |
46-
| `{{ constraint }}` | The comparison/minimum value |
42+
| Parameter | Description |
43+
|--------------------|-----------------------------------|
44+
| `{{ value }}` | The current invalid value |
45+
| `{{ name }}` | Name of the value being validated |
46+
| `{{ constraint }}` | The comparison value |

docs/03-rules-greater-than.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Check the [Custom Messages]() section for more information.
3535

3636
The following parameters are available:
3737

38-
| Parameter | Description |
39-
|--------------------|------------------------------------|
40-
| `{{ value }}` | The current invalid value |
41-
| `{{ name }}` | Name of the value being validated |
42-
| `{{ constraint }}` | The comparison/minimum value |
38+
| Parameter | Description |
39+
|--------------------|-----------------------------------|
40+
| `{{ value }}` | The current invalid value |
41+
| `{{ name }}` | Name of the value being validated |
42+
| `{{ constraint }}` | The comparison value |

docs/03-rules-less-than.md

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

0 commit comments

Comments
 (0)