respect-validation/library/Exceptions/OptionalException.php
2015-10-07 02:44:33 -03:00

33 lines
892 B
PHP

<?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.
*/
namespace Respect\Validation\Exceptions;
class OptionalException extends ValidationException
{
const STANDARD = 0;
const NAMED = 1;
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => 'The value must be optional',
self::NAMED => '{{name}} must be optional',
),
self::MODE_NEGATIVE => array(
self::STANDARD => 'The value is required',
self::NAMED => '{{name}} is required',
),
);
public function chooseTemplate()
{
return $this->getName() == '' ? static::STANDARD : static::NAMED;
}
}