respect-validation/src/Validators/Control.php
Henrique Moody 140bd36aa3
Rename library/ to src/
We've always considered renaming this directory, as it's not a common
standard to name `library` the directory where the source code of a
library it. Having it as `src/` is a common pattern we find in several
PHP libraries these days.

Acked-by: Alexandre Gomes Gaigalas <alganet@gmail.com>
2026-01-22 13:13:15 +01:00

41 lines
1.2 KiB
PHP

<?php
/*
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: (c) Respect Project Contributors
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-FileContributor: Andre Ramaciotti <andre@ramaciotti.com>
* SPDX-FileContributor: Danilo Correa <danilosilva87@gmail.com>
* SPDX-FileContributor: Graham Campbell <graham@mineuk.com>
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
* SPDX-FileContributor: Nick Lombard <github@jigsoft.co.za>
*/
declare(strict_types=1);
namespace Respect\Validation\Validators;
use Attribute;
use Respect\Validation\Message\Template;
use Respect\Validation\Validators\Core\FilteredString;
use function ctype_cntrl;
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
#[Template(
'{{subject}} must only contain control characters',
'{{subject}} must not contain control characters',
self::TEMPLATE_STANDARD,
)]
#[Template(
'{{subject}} must only contain control characters and {{additionalChars}}',
'{{subject}} must not contain control characters or {{additionalChars}}',
self::TEMPLATE_EXTRA,
)]
final class Control extends FilteredString
{
protected function isValid(string $input): bool
{
return ctype_cntrl($input);
}
}