mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 15:50:03 +01:00
This change will bring many breaking changes. The good thing is that we can finally use more modern resources available in PHP. I can imagine that's not a popular change since it will bring many breaking changes to users, but we shouldn't be stuck in time because of that. Using some of those features will make it easier to contribute to the project. At least, I hope so. There are still some useless doc-blocks, and we're not using "readonly" properties when we could. I aim to send those changes soon. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
38 lines
909 B
PHP
38 lines
909 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Exceptions;
|
|
|
|
final class NullableException extends ValidationException
|
|
{
|
|
public const NAMED = 'named';
|
|
|
|
/**
|
|
* @var array<string, array<string, string>>
|
|
*/
|
|
protected array $defaultTemplates = [
|
|
self::MODE_DEFAULT => [
|
|
self::STANDARD => 'The value must be nullable',
|
|
self::NAMED => '{{name}} must be nullable',
|
|
],
|
|
self::MODE_NEGATIVE => [
|
|
self::STANDARD => 'The value must not be null',
|
|
self::NAMED => '{{name}} must not be null',
|
|
],
|
|
];
|
|
|
|
protected function chooseTemplate(): string
|
|
{
|
|
if ($this->getParam('input') || $this->getParam('name')) {
|
|
return self::NAMED;
|
|
}
|
|
|
|
return self::STANDARD;
|
|
}
|
|
}
|