docs/validators/Trimmed.md
Trimmed()Trimmed(string ...$trimValues)Validates whether the input string does not start or end with the given values.
When no values are provided, this validator uses a default list of Unicode invisible characters (including regular whitespace, non-breaking spaces, and zero-width characters).
With the default values:
v::trimmed()->assert('lorem ipsum');
// Validation passes successfully
v::trimmed()->assert("\u{200B}lorem");
// → "lorem" must not contain leading or trailing whitespace
With custom values:
v::trimmed('Dr.', 'Mr.', 'PhD.')->assert('John');
// Validation passes successfully
v::trimmed('Dr.', 'Mr.', 'PhD.')->assert('Dr. John');
// → "Dr. John" must not contain leading or trailing "Dr.", "Mr.", or "PhD."
v::trimmed('Dr.', 'Mr.', ', PhD')->assert('John Doe, PhD');
// → "John Doe, PhD" must not contain leading or trailing "Dr.", "Mr.", or ", PhD"
This validator composes StartsWith and EndsWith.
Trimmed::TEMPLATE_STANDARD| Mode | Template |
|---|---|
default | {{subject}} must not contain leading or trailing whitespace |
inverted | {{subject}} must contain leading or trailing whitespace |
Trimmed::TEMPLATE_CUSTOM| Mode | Template |
|---|---|
default | {{subject}} must not contain leading or trailing {{trimValues|list:or}} |
inverted | {{subject}} must contain leading or trailing {{trimValues|list:or}} |
| Placeholder | Description |
|---|---|
subject | The validated input or the custom validator name (if specified). |
trimValues | The values that will be checked at start end end of input. |
| Version | Description |
|---|---|
| 3.1.0 | Created |