Length range
The length of the text associated with the given (key
) shall be within a specified range.
Parameter table
param | unit | required | description |
---|---|---|---|
key | yes | The key of the text to check for length. | |
min | char | no | The minimum length allowed. |
max | char | no | The maximum length allowed. |
applyCorrection | no | Whether to apply the correction. |
Correction
The correction is implemented on the provided (key
),
the correction can only be done if the text is longer than the maximum length.
The text is transformed into a new one with a length three characters less than the specified (maxLength).
This transformation includes the concatenation of ...,
signifying that the text exceeded the designated length and underwent correction.
There are cases where we won't be performing the described correction on the text
as it doesn't make sense to remove characters from it.
So, any text with length smaller than 10 will not be corrected even if it is greater than the maximum length.
How to setup
The rule verifies whether the text associated with the specified (key
) is within the specified range
defined by the minimum (min
) and maximum (max
) lengths. If the text is not within the specified range,
the rule will fail.
Examples
value | valid | max | min | description |
---|---|---|---|---|
Lyon | ❌ | 6 | The text is shorter than the minimum length. | |
Aix-en-Provence | ✅ | 6 | The text is longer than the minimum length. | |
The weather is nice today. | ❌ | 10 | The text is longer than the maximum length. | |
Mercedes | ✅ | 10 | The text is shorter than the maximum length. | |
hi there | ✅ | 10 | 5 | The text is within the specified range. |
hello | ✅ | 5 | 5 | The text is within the specified range. |
hi | ❌ | 10 | 5 | The text is shorter than the minimum length. |
The weather is nice today. | ❌ | 10 | 5 | The text is longer than the maximum length. |