Back to Validation

Between

docs/validators/Between.md

3.1.12.1 KB
Original Source
<!-- SPDX-License-Identifier: MIT SPDX-FileCopyrightText: (c) Respect Project Contributors SPDX-FileContributor: Alexandre Gomes Gaigalas <[email protected]> SPDX-FileContributor: Henrique Moody <[email protected]> -->

Between

  • Between(mixed $minValue, mixed $maxValue)

Validates whether the input is between two other values.

php
v::intVal()->between(10, 20)->assert(10);
// Validation passes successfully

v::intVal()->between(10, 20)->assert(15);
// Validation passes successfully

v::intVal()->between(10, 20)->assert(20);
// Validation passes successfully

Validation makes comparison easier, check out our supported comparable values.

Message template for this validator includes {{minValue}} and {{maxValue}}.

Templates

Between::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be between {{minValue}} and {{maxValue}}
inverted{{subject}} must not be between {{minValue}} and {{maxValue}}

Template placeholders

PlaceholderDescription
maxValueThe minimum value passed to the validator.
minValueThe maximum value passed to the validator.
subjectThe validated input or the custom validator name (if specified).

Categorization

  • Comparisons

Changelog

VersionDescription
2.0.0Became always inclusive
1.0.0Became inclusive by default
0.3.9Created

See Also