respect-validation/library/Exceptions/KeyValueException.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2015-10-08 18:54:42 +02:00
<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
2015-10-08 18:54:42 +02:00
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
2015-10-08 18:54:42 +02:00
*/
declare(strict_types=1);
2015-10-08 18:54:42 +02:00
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class KeyValueException extends ValidationException
2015-10-08 18:54:42 +02:00
{
public const COMPONENT = 'component';
2015-10-08 18:54:42 +02:00
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
2015-10-18 03:44:47 +02:00
self::MODE_DEFAULT => [
2015-10-08 18:54:42 +02:00
self::STANDARD => 'Key {{name}} must be present',
self::COMPONENT => '{{baseKey}} must be valid to validate {{comparedKey}}',
2015-10-18 03:44:47 +02:00
],
self::MODE_NEGATIVE => [
2015-10-08 18:54:42 +02:00
self::STANDARD => 'Key {{name}} must not be present',
self::COMPONENT => '{{baseKey}} must not be valid to validate {{comparedKey}}',
2015-10-18 03:44:47 +02:00
],
];
2015-10-08 18:54:42 +02:00
protected function chooseTemplate(): string
2015-10-08 18:54:42 +02:00
{
return $this->getParam('component') ? self::COMPONENT : self::STANDARD;
2015-10-08 18:54:42 +02:00
}
}