Back to Validation

StringVal

docs/validators/StringVal.md

3.1.11.8 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]> SPDX-FileContributor: yoshihiro suzuki <[email protected]> -->

StringVal

  • StringVal()

Validates whether the input can be used as a string.

php
v::stringVal()->assert('6');
// Validation passes successfully

v::stringVal()->assert('String');
// Validation passes successfully

v::stringVal()->assert(1.0);
// Validation passes successfully

v::stringVal()->assert(42);
// Validation passes successfully

v::stringVal()->assert(false);
// Validation passes successfully

v::stringVal()->assert(true);
// Validation passes successfully

v::stringVal()->assert(new ClassWithToString());
// Validation passes successfully

Templates

StringVal::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be a string
inverted{{subject}} must not be a string

Template placeholders

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

Categorization

  • Strings
  • Types

Changelog

VersionDescription
3.0.0Templates changed
2.0.0Created

See Also