mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 23:59:51 +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>
35 lines
1,007 B
PHP
35 lines
1,007 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 KeyNestedException extends NestedValidationException implements NonOmissibleException
|
|
{
|
|
public const NOT_PRESENT = 'not_present';
|
|
public const INVALID = 'invalid';
|
|
|
|
/**
|
|
* @var array<string, array<string, string>>
|
|
*/
|
|
protected array $defaultTemplates = [
|
|
self::MODE_DEFAULT => [
|
|
self::NOT_PRESENT => 'No items were found for key chain {{name}}',
|
|
self::INVALID => 'Key chain {{name}} is not valid',
|
|
],
|
|
self::MODE_NEGATIVE => [
|
|
self::NOT_PRESENT => 'Items for key chain {{name}} must not be present',
|
|
self::INVALID => 'Key chain {{name}} must not be valid',
|
|
],
|
|
];
|
|
|
|
protected function chooseTemplate(): string
|
|
{
|
|
return $this->getParam('hasReference') ? self::INVALID : self::NOT_PRESENT;
|
|
}
|
|
}
|