@@ -31,16 +31,6 @@ The supported types are:
3131
3232## Templates
3333
34- The first two templates serve as message suffixes:
35-
36- ``` php
37- v::dateTimeDiff('years', v::equals(2))->assert('1 year ago')
38- // The number of years between now and 1 year ago must be equal to 2
39-
40- v::not(v::dateTimeDiff('years', v::lessThan(8)))->assert('7 year ago')
41- // The number of years between now and 7 year ago must not be less than 8
42- ```
43-
4434### ` DateTimeDiff::TEMPLATE_STANDARD `
4535
4636Used when ` $format ` and ` $now ` are not defined.
@@ -54,10 +44,17 @@ Used when `$format` and `$now` are not defined.
5444
5545Used when ` $format ` or ` $now ` are defined.
5646
57- | Mode | Template |
58- | ---------- | -------------------------------------------------------------- |
59- | ` default ` | The number of {{type| ; trans}} between {{now| ; raw}} and |
60- | ` inverted ` | The number of {{type| ; trans}} between {{now| ; raw}} and |
47+ | Mode | Template |
48+ | ---------- | ----------------------------------------------------- |
49+ | ` default ` | The number of {{type| ; trans}} between {{now}} and |
50+ | ` inverted ` | The number of {{type| ; trans}} between {{now}} and |
51+
52+ ### ` DateTimeDiff::TEMPLATE_NOT_A_DATE `
53+
54+ | Mode | Template |
55+ | ---------- | ------------------------------------------------------------------------------ |
56+ | ` default ` | For comparison with {{now| ; raw}}, {{subject}} must be a valid datetime |
57+ | ` inverted ` | For comparison with {{now| ; raw}}, {{subject}} must not be a valid datetime |
6158
6259### ` DateTimeDiff::TEMPLATE_WRONG_FORMAT `
6360
@@ -68,6 +65,18 @@ Used when the input cannot be parsed with the given format.
6865| ` default ` | For comparison with {{now| ; raw}}, {{subject}} must be a valid datetime in the format {{sample| ; raw}} |
6966| ` inverted ` | For comparison with {{now| ; raw}}, {{subject}} must not be a valid datetime in the format {{sample| ; raw}} |
7067
68+ ## Template as prefix
69+
70+ The template serves as a prefix to the template of the inner validator.
71+
72+ ``` php
73+ v::dateTimeDiff('years', v::equals(2))->assert('1 year ago')
74+ // The number of years between now and 1 year ago must be equal to 2
75+
76+ v::not(v::dateTimeDiff('years', v::lessThan(8)))->assert('7 year ago')
77+ // The number of years between now and 7 year ago must not be less than 8
78+ ```
79+
7180## Template placeholders
7281
7382| Placeholder | Description |
0 commit comments