StartsWith(mixed $startValue)StartsWith(mixed $startValue, mixed ...$startValues)
Validates whether the input starts with one of the given values.
This validator is similar to Contains, but validates only if the value is at the beginning of the input.
For strings:
v::startsWith('lorem')->assert('lorem ipsum');
// Validation passes successfully
v::startsWith('Dr.', 'Mr.')->assert('Dr. Jane Doe');
// Validation passes successfullyFor arrays:
v::startsWith('lorem')->assert(['lorem', 'ipsum']);
// Validation passes successfully
v::startsWith(0, 1)->assert([0, 1, 2, 3]);
// Validation passes successfully
v::startsWith(0, 1)->assert([1, 2, 3]);
// Validation passes successfullyMessage template for this validator includes {{startValue}} and {{startValues}}.
| Mode | Template |
|---|---|
default |
{{subject}} must start with {{startValue}} |
inverted |
{{subject}} must not start with {{startValue}} |
| Mode | Template |
|---|---|
default |
{{subject}} must start with {{startValues|list:or}} |
inverted |
{{subject}} must not start with {{startValues|list:or}} |
| Placeholder | Description |
|---|---|
subject |
The validated input or the custom validator name (if specified). |
startValue |
The value that will be checked to be at the start of the input. |
startValues |
Additional values to check. |
- Arrays
- Strings
| Version | Description |
|---|---|
| 3.1.0 | Added support for multiple values |
| 3.0.0 | Case-insensitive comparison removed |
| 0.3.9 | Created |