respect-validation/docs/rules/StartsWith.md
2024-12-09 01:34:50 +01:00

1.4 KiB

StartsWith

  • StartsWith(mixed $value)
  • StartsWith(mixed $value, bool $identical)

Validates whether the input starts with a given value.

This validator is similar to Contains, but validates only if the value is at the beginning of the input.

For strings:

v::startsWith('lorem')->isValid('lorem ipsum'); // true

For arrays:

v::startsWith('lorem')->isValid(['lorem', 'ipsum']); // true

true may be passed as a parameter to indicate identical comparison instead of equal.

Message template for this validator includes {{startValue}}.

Templates

StartsWith::TEMPLATE_STANDARD

Mode Template
default {{name}} must start with {{startValue}}
inverted {{name}} must not start with {{startValue}}

Template placeholders

Placeholder Description
name The validated input or the custom validator name (if specified).
startValue

Categorization

  • Arrays
  • Strings

Changelog

Version Description
0.3.9 Created

See also: