This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # GreaterThan
2+
3+ Validates that a value is greater than 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(1.5)->validate(2.5); // true
10+ Validator::greaterThan('alpha')->validate('beta'); // true
11+ Validator::greaterThan(new DateTime('today'))->validate(new DateTime('tomorrow')); // 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/minimum value. Can be a string, number or ` DateTimeInterface ` object.
28+
29+ ### ` message `
30+
31+ type: ` string ` default: ` The "{{ name }}" value should be greater than "{{ constraint }}", "{{ value }}" given. `
32+
33+ Message that will be shown if the value is not greater than the constraint value. Check the [ Custom Messages] ( ) section for more information.
34+
35+ The following parameters are available:
36+
37+ | Parameter | Description |
38+ | --------------------| ------------------------------------|
39+ | ` {{ value }} ` | The current invalid value |
40+ | ` {{ name }} ` | Name of the value being validated |
41+ | ` {{ constraint }} ` | The comparison/minimum value |
You can’t perform that action at this time.
0 commit comments