Back to Validation

Odd

docs/validators/Odd.md

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

Odd

  • Odd()

Validates whether the input is an odd number or not.

php
v::odd()->assert(3);
// Validation passes successfully

v::odd()->assert(0);
// → 0 must be an odd number

Using intVal() before odd() is a best practice.

Templates

Odd::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be an odd number
inverted{{subject}} must be an even number

Template placeholders

PlaceholderDescription
subjectThe validated input or the custom validator name (if specified).

Categorization

  • Numbers

Changelog

VersionDescription
2.0.0Only validates integers
0.3.9Created

See Also