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.
|
|
|
|
*/
|
|
|
|
|
2017-11-19 19:01:31 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2015-07-20 12:16:46 +02:00
|
|
|
namespace Respect\Validation\Exceptions;
|
|
|
|
|
2018-05-24 08:25:57 +02:00
|
|
|
class KeySetException extends GroupedValidationException implements NonOmissibleException
|
2015-07-20 12:16:46 +02:00
|
|
|
{
|
2018-05-23 10:07:41 +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}
|
|
|
|
*/
|
2018-05-23 10:07:41 +02:00
|
|
|
public function chooseTemplate(): string
|
2015-07-20 12:16:46 +02:00
|
|
|
{
|
2018-03-03 18:59:36 +01:00
|
|
|
if (0 === $this->getRelated()->count()) {
|
2015-07-20 12:16:46 +02:00
|
|
|
return static::STRUCTURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::chooseTemplate();
|
|
|
|
}
|
|
|
|
}
|