Back to Validation

Charset

docs/validators/Charset.md

3.1.12.0 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]> -->

Charset

  • Charset(string $charset)
  • Charset(string $charset, string ...$charsets)

Validates if a string is in a specific charset.

php
v::charset('ASCII')->assert('sugar');
// Validation passes successfully

v::charset('ASCII')->assert('açúcar');
// → "açúcar" must consist only of characters from the "ASCII" character-set

v::charset('ISO-8859-1', 'EUC-JP')->assert('日本国');
// Validation passes successfully

The array format is a logic OR, not AND.

Templates

Charset::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must consist only of characters from the {{charset|list:or}} character-set
inverted{{subject}} must not consist only of characters from the {{charset|list:or}} character-set

Template placeholders

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

Categorization

  • Strings

Changelog

VersionDescription
3.0.0Templates changed
2.0.0Charset supports multiple charsets on its constructor
0.5.0Created

See Also