respect-validation/library/Exceptions/KeySetException.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2015-07-20 12:16:46 +02:00
<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* For the full copyright and license information, please view the "LICENSE.md"
* file that was distributed with this source code.
*/
declare(strict_types=1);
2015-07-20 12:16:46 +02:00
namespace Respect\Validation\Exceptions;
class KeySetException extends GroupedValidationException implements NonOmissibleException
2015-07-20 12:16:46 +02:00
{
public const STRUCTURE = 'structure';
2015-07-20 12:16:46 +02:00
/**
* @var array
*/
2015-10-18 03:44:47 +02:00
public static $defaultTemplates = [
self::MODE_DEFAULT => [
2015-07-20 12:16:46 +02:00
self::NONE => 'All of the required rules must pass for {{name}}',
self::SOME => 'These rules must pass for {{name}}',
self::STRUCTURE => 'Must have keys {{keys}}',
2015-10-18 03:44:47 +02:00
],
self::MODE_NEGATIVE => [
2015-07-20 12:16:46 +02:00
self::NONE => 'None of these rules must pass for {{name}}',
self::SOME => 'These rules must not pass for {{name}}',
self::STRUCTURE => 'Must not have keys {{keys}}',
2015-10-18 03:44:47 +02:00
],
];
2015-07-20 12:16:46 +02:00
/**
* {@inheritdoc}
*/
public function chooseTemplate(): string
2015-07-20 12:16:46 +02:00
{
if (0 === $this->getRelated()->count()) {
2015-07-20 12:16:46 +02:00
return static::STRUCTURE;
}
return parent::chooseTemplate();
}
}