This commit is contained in:
2023-01-02 19:56:44 +08:00
commit e187878b7a
3244 changed files with 260239 additions and 0 deletions
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
class AllOfException extends GroupedValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::NONE => '{{name}} 必需符合以下规则',
self::SOME => '{{name}} 必需符合以下规则',
],
self::MODE_NEGATIVE => [
self::NONE => '{{name}} 不能符合以下规则',
self::SOME => '{{name}} 不能符合以下规则',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class AlnumException extends FilteredValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 只能包含字母(a-z)和数字(0-9)',
self::EXTRA => '{{name}} 只能包含字母(a-z)、数字(0-9)和 {{additionalChars}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含字母(a-z)或数字(0-9)',
self::EXTRA => '{{name}} 不能包含字母(a-z)、数字(0-9)或 {{additionalChars}}',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class AlphaException extends FilteredValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 只能包含字母(a-z',
self::EXTRA => '{{name}} 只能包含字母(a-z)和 {{additionalChars}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含字母(a-z',
self::EXTRA => '{{name}} 不能包含字母(a-z)或 {{additionalChars}}',
],
];
}
@@ -0,0 +1,38 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class AlwaysInvalidException extends ValidationException
{
public const SIMPLE = 'simple';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 始终无效',
self::SIMPLE => '{{name}} 无效',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 始终有效',
self::SIMPLE => '{{name}} 有效',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class AlwaysValidException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 始终有效',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 始终无效',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class AnyOfException extends NestedValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '这些规则中至少有一个必须传递给 {{name}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '这些规则中至少有一个不能传递给 {{name}}',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author João Torquato <joao.otl@gmail.com>
*/
final class ArrayTypeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是array类型',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是array类型',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class ArrayValException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是数组',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是数组',
],
];
}
@@ -0,0 +1,49 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exceptions to be thrown by the Attribute Rule.
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class AttributeException extends NestedValidationException implements NonOmissibleException
{
public const NOT_PRESENT = 'not_present';
public const INVALID = 'invalid';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::NOT_PRESENT => '属性 {{name}} 必须存在',
self::INVALID => '属性 {{name}} 必须有效',
],
self::MODE_NEGATIVE => [
self::NOT_PRESENT => '属性 {{name}} 不能存在',
self::INVALID => '属性 {{name}} 必须无效',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
return $this->getParam('hasReference') ? self::INVALID : self::NOT_PRESENT;
}
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jens Segers <segers.jens@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class Base64Exception extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须采用Base64编码',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是Base64编码',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Carlos André Ferrari <caferrari@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class BaseException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是基于 {{base}} 中的数字',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是基于 {{base}} 中的数字',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class BetweenException extends NestedValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须介于 {{minValue}} 和 {{maxValue}} 之间',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能介于 {{minValue}} 和 {{maxValue}} 之间',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exception class for BoolType rule.
*
* @author Devin Torres <devin@devintorres.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class BoolTypeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是boolean类型',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是boolean类型',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class BoolValException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是布尔值',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是布尔值',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Ronald Drenth <ronalddrenth@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class BsnException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是BSN',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是BSN',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class CallException extends NestedValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '当使用 {{callable}} 时 {{input}} 必须有效',
],
self::MODE_NEGATIVE => [
self::STANDARD => '当使用 {{callable}} 时 {{input}} 必须无效',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exception class for CallableType rule.
*
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class CallableTypeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是可调用的',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是可调用的',
],
];
}
@@ -0,0 +1,23 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CallbackException extends NestedValidationException
{
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CharsetException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须在 {{charset}} 字符集中',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能在 {{charset}} 字符集中',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Kinn Coelho Julião <kinncj@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CnhException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的CNH号码',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的CNH号码',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Leonn Leite <leonnleite@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CnpjException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的CNPJ编号',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的CNPJ编号',
],
];
}
@@ -0,0 +1,25 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
use Exception;
use Throwable;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
class ComponentException extends Exception implements Throwable
{
}
@@ -0,0 +1,36 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Kleber Hamada Sato <kleberhs007@yahoo.com>
*/
final class ConsonantException extends FilteredValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 只能包含辅音',
self::EXTRA => '{{name}} 只能包含辅音和 {{additionalChars}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含辅音',
self::EXTRA => '{{name}} 不能包含辅音或 {{additionalChars}}',
],
];
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Kirill Dlussky <kirill@dlussky.ru>
*/
final class ContainsAnyException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须包含至少一个值 {{needles}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含任何值 {{needles}}',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class ContainsException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须包含值 {{containsValue}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含值 {{containsValue}}',
],
];
}
@@ -0,0 +1,36 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Andre Ramaciotti <andre@ramaciotti.com>
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class ControlException extends FilteredValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 只能包含控制字符',
self::EXTRA => '{{name}} 只能包含控制字符和 {{additionalChars}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含控制字符',
self::EXTRA => '{{name}} 不能包含控制字符或 {{additionalChars}}',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author João Torquato <joao.otl@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CountableException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是可数的',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是可数的',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CountryCodeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的国家/地区',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的国家/地区',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jair Henrique <jair.henrique@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CpfException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的CPF编号',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的CPF编号',
],
];
}
@@ -0,0 +1,52 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
use Respect\Validation\Rules\CreditCard;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jean Pimentel <jeanfap@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CreditCardException extends ValidationException
{
public const BRANDED = 'branded';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的信用卡号',
self::BRANDED => '{{name}} 必须是有效的 {{brand}} 信用卡号',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的信用卡号',
self::BRANDED => '{{name}} 不能是有效的 {{brand}} 信用卡号',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
if ($this->getParam('brand') === CreditCard::ANY) {
return self::STANDARD;
}
return self::BRANDED;
}
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Justin Hook <justinhook88@yahoo.co.uk>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class CurrencyCodeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的货币',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的货币',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Bruno Luiz da Silva <contato@brunoluiz.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class DateException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是格式为 {{sample}} 的有效日期',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是格式为 {{sample}} 的日期',
],
];
}
@@ -0,0 +1,45 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class DateTimeException extends ValidationException
{
public const FORMAT = 'format';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的日期/时间',
self::FORMAT => '{{name}} 必须是格式为 {{sample}} 的有效日期/时间',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的日期/时间',
self::FORMAT => '{{name}} 不能是格式为 {{sample}} 的有效日期/时间',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
return $this->getParam('format') ? self::FORMAT : self::STANDARD;
}
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class DigitException extends FilteredValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 只能包含数字(0-9',
self::EXTRA => '{{name}} 只能包含数字(0-9)和 {{additionalChars}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含数字(0-9',
self::EXTRA => '{{name}} 只能包含数字(0-9)和 {{additionalChars}}',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class DirectoryException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是目录',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是目录',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class DomainException extends NestedValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效域名',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效域名',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class EachException extends NestedValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 中的每个项都必须有效',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 中的每个项都必须无效',
],
];
}
@@ -0,0 +1,38 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exceptions thrown by email rule.
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Andrey Kolyshkin <a.kolyshkin@semrush.com>
* @author Eduardo Gulias Davis <me@egulias.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Paul Karikari <paulkarikari1@gmail.com>
*/
final class EmailException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的电子邮件',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是电子邮件',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class EndsWithException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须以 {{endValue}} 结尾',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能以 {{endValue}} 结尾',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Ian Nisbet <ian@glutenite.co.uk>
*/
final class EqualsException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须等于 {{compareTo}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能等于 {{compareTo}}',
],
];
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class EquivalentException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须与 {{compareTo}} 相等',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能与 {{compareTo}} 相等',
],
];
}
@@ -0,0 +1,36 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exceptions to be thrown by the Even Rule.
*
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jean Pimentel <jeanfap@gmail.com>
* @author Paul Karikari <paulkarikari1@gmail.com>
*/
final class EvenException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是偶数',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是偶数',
],
];
}
@@ -0,0 +1,24 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
use Throwable;
/**
* @author Andy Wendt <andy@awendt.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
interface Exception extends Throwable
{
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class ExecutableException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是可执行文件',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是可执行文件',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author William Espindola <oi@williamespindola.com.br>
*/
final class ExistsException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须存在',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能存在',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exception class for Extension rule.
*
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class ExtensionException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是 {{extension}} 后缀',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是 {{extension}} 后缀',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Correa <danilosilva87@gmail.com>
* @author David Meister <thedavidmeister@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class FactorException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是 {{dividend}} 的因子',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是 {{dividend}} 的因子',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class FalseValException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 不被视为 "False"',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 可视为 "False"',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Samuel Heinzmann <samuel.heinzmann@swisscom.com>
*/
final class FibonacciException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的斐波纳契数',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的斐波纳契数',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class FileException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是文件',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是文件',
],
];
}
@@ -0,0 +1,21 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class FilterVarException extends ValidationException
{
}
@@ -0,0 +1,30 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
class FilteredValidationException extends ValidationException
{
public const EXTRA = 'extra';
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
return $this->getParam('additionalChars') ? self::EXTRA : self::STANDARD;
}
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class FiniteException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有限数',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有限数',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exception class for FloatType rule.
*
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Reginaldo Junior <76regi@gmail.com>
*/
final class FloatTypeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是float类型',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是float类型',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class FloatValException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是浮点数',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是浮点数',
],
];
}
@@ -0,0 +1,36 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Andre Ramaciotti <andre@ramaciotti.com>
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class GraphException extends FilteredValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 只能包含图形字符',
self::EXTRA => '{{name}} 只能包含图形字符和 {{additionalChars}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能包含图形字符',
self::EXTRA => '{{name}} 不能包含图形字符或 {{additionalChars}}',
],
];
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class GreaterThanException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须大于 {{compareTo}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能大于 {{compareTo}}',
],
];
}
@@ -0,0 +1,51 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
use function count;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
class GroupedValidationException extends NestedValidationException
{
public const NONE = 'none';
public const SOME = 'some';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::NONE => '所有必需的规则都必须传递给 {{name}}',
self::SOME => '这些规则必须传递给 {{name}}',
],
self::MODE_NEGATIVE => [
self::NONE => '所有规则都不能传递给 {{name}}',
self::SOME => '这些规则不能传递给 {{name}}',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
$numRules = $this->getParam('passed');
$numFailed = count($this->getChildren());
return $numRules === $numFailed ? self::NONE : self::SOME;
}
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Davide Pastore <pasdavide@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class HexRgbColorException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是十六进制RGB颜色',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是十六进制RGB颜色',
],
];
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Mazen Touati <mazen_touati@hotmail.com>
*/
final class IbanException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的IBAN',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的IBAN',
],
];
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class IdenticalException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须与 {{compareTo}} 相同',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能与 {{compareTo}} 相同',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Guilherme Siani <guilherme@siani.com.br>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class ImageException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的图像',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的图像',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Diego Oliveira <contato@diegoholiveira.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class ImeiException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的IMEI',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的IMEI',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class InException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须在 {{haystack}} 中',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能在 {{haystack}} 中',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class InfiniteException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是无穷大的数字',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是无穷大的数字',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class InstanceException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是 {{instanceName}} 的实例',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是 {{instanceName}} 的实例',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exception class for IntType rule.
*
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class IntTypeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是integer类型',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是integer类型',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class IntValException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是整数',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是整数',
],
];
}
@@ -0,0 +1,25 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exception for invalid classes.
*
* @since 2.0.0
*
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class InvalidClassException extends ComponentException
{
}
@@ -0,0 +1,51 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>
*/
final class IpException extends ValidationException
{
public const NETWORK_RANGE = 'network_range';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是IP地址',
self::NETWORK_RANGE => '{{name}} 必须是 {{range}} 范围内的IP地址',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是IP地址',
self::NETWORK_RANGE => '{{name}} 不能是 {{range}} 范围内的IP地址',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
if (!$this->getParam('range')) {
return self::STANDARD;
}
return self::NETWORK_RANGE;
}
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Moritz Fromm <moritzgitfromm@gmail.com>
*/
final class IsbnException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是ISBN',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是ISBN',
],
];
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class IterableTypeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是可迭代的',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是可迭代的',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class JsonException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的JSON字符串',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的JSON字符串',
],
];
}
@@ -0,0 +1,49 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exceptions to be thrown by the Attribute Rule.
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class KeyException extends NestedValidationException implements NonOmissibleException
{
public const NOT_PRESENT = 'not_present';
public const INVALID = 'invalid';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::NOT_PRESENT => '键 {{name}} 必须存在',
self::INVALID => '键 {{name}} 必须有效',
],
self::MODE_NEGATIVE => [
self::NOT_PRESENT => '键 {{name}} 不能存在',
self::INVALID => '键 {{name}} 必须无效',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
return $this->getParam('hasReference') ? self::INVALID : self::NOT_PRESENT;
}
}
@@ -0,0 +1,49 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exceptions to be thrown by the Attribute Rule.
*
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Ivan Zinovyev <vanyazin@gmail.com>
*/
final class KeyNestedException extends NestedValidationException implements NonOmissibleException
{
public const NOT_PRESENT = 'not_present';
public const INVALID = 'invalid';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::NOT_PRESENT => '找不到密钥链 {{name}} 的项',
self::INVALID => '密钥链 {{name}} 无效',
],
self::MODE_NEGATIVE => [
self::NOT_PRESENT => '密钥链 {{name}} 的项不存在',
self::INVALID => '密钥链 {{name}} 必须无效',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
return $this->getParam('hasReference') ? self::INVALID : self::NOT_PRESENT;
}
}
@@ -0,0 +1,52 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
use function count;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class KeySetException extends GroupedValidationException implements NonOmissibleException
{
public const STRUCTURE = 'structure';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::NONE => '所有必需的规则都必须传递给 {{name}}',
self::SOME => '这些规则必须传递给 {{name}}',
self::STRUCTURE => '必须有键 {{keys}}',
],
self::MODE_NEGATIVE => [
self::NONE => '这些规则都不能传递给 {{name}}',
self::SOME => '这些规则不能传递给 {{name}}',
self::STRUCTURE => '不能有键 {{keys}}',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
if (count($this->getChildren()) === 0) {
return self::STRUCTURE;
}
return parent::chooseTemplate();
}
}
@@ -0,0 +1,41 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class KeyValueException extends ValidationException
{
public const COMPONENT = 'component';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '键 {{name}} 必须存在',
self::COMPONENT => '{{baseKey}} 必须有效才能验证 {{comparedKey}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '键 {{name}} 不能存在',
self::COMPONENT => '{{baseKey}} 必须无效才能验证 {{comparedKey}}',
],
];
protected function chooseTemplate(): string
{
return $this->getParam('component') ? self::COMPONENT : self::STANDARD;
}
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class LanguageCodeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的 ISO 639 {{set}} 语言编码',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的 ISO 639 {{set}} 语言编码',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class LeapDateException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是闰日',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是闰日',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class LeapYearException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是闰年',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是闰年',
],
];
}
@@ -0,0 +1,74 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Mazen Touati <mazen_touati@hotmail.com>
*/
final class LengthException extends ValidationException
{
public const BOTH = 'both';
public const LOWER = 'lower';
public const LOWER_INCLUSIVE = 'lower_inclusive';
public const GREATER = 'greater';
public const GREATER_INCLUSIVE = 'greater_inclusive';
public const EXACT = 'exact';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::BOTH => '{{name}} 长度必须在 {{minValue}} 与 {{maxValue}} 之间',
self::LOWER => '{{name}} 长度必须大于 {{minValue}}',
self::LOWER_INCLUSIVE => '{{name}} 的长度必须大于或等于 {{minValue}}',
self::GREATER => '{{name}} 长度必须小于 {{maxValue}}',
self::GREATER_INCLUSIVE => '{{name}} 长度必须小于或等于 {{maxValue}}',
self::EXACT => '{{name}} 长度必须是 {{maxValue}}',
],
self::MODE_NEGATIVE => [
self::BOTH => '{{name}} 的长度不能介于 {{minValue}} 和 {{maxValue}} 之间',
self::LOWER => '{{name}} 长度不能大于 {{minValue}}',
self::LOWER_INCLUSIVE => '{{name}} 长度不能大于或等于 {{minValue}}',
self::GREATER => '{{name}} 长度不得小于 {{maxValue}}',
self::GREATER_INCLUSIVE => '{{name}} 长度不能小于或等于 {{maxValue}}',
self::EXACT => '{{name}} 长度不能是 {{maxValue}}',
],
];
/**
* {@inheritDoc}
*/
protected function chooseTemplate(): string
{
$isInclusive = $this->getParam('inclusive');
if (!$this->getParam('minValue')) {
return $isInclusive === true ? self::GREATER_INCLUSIVE : self::GREATER;
}
if (!$this->getParam('maxValue')) {
return $isInclusive === true ? self::LOWER_INCLUSIVE : self::LOWER;
}
if ($this->getParam('minValue') == $this->getParam('maxValue')) {
return self::EXACT;
}
return self::BOTH;
}
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class LessThanException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须小于 {{compareTo}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能小于 {{compareTo}}',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jean Pimentel <jeanfap@gmail.com>
*/
final class LowercaseException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是小写',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是小写',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexander Gorshkov <mazanax@yandex.ru>
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class LuhnException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的Luhn编号',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的Luhn编号',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Fábio da Silva Ribeiro <fabiorphp@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class MacAddressException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的MAC地址',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的MAC地址',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class MaxAgeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是 {{age}} 年或者更少',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是 {{age}} 年或者更少',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Andrew Peters <amp343@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class MaxException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须小于或等于 {{compareTo}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能小于或等于 {{compareTo}}',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* Exception class for Mimetype rule.
*
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class MimetypeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须具有 {{mimetype}} MIME类型',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能有 {{mimetype}} MIME类型',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jean Pimentel <jeanfap@gmail.com>
*/
final class MinAgeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是 {{age}} 必须是年或以上',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是 {{age}} 年或更长',
],
];
}
@@ -0,0 +1,35 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class MinException extends ValidationException
{
public const INCLUSIVE = 'inclusive';
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须大于或等于 {{compareTo}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能大于或等于 {{compareTo}}',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jean Pimentel <jeanfap@gmail.com>
*/
final class MultipleException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是 {{multipleOf}} 的倍数',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是 {{multipleOf}} 的倍数',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Ismael Elias <ismael.esq@hotmail.com>
*/
final class NegativeException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须为负数',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能为负数',
],
];
}
@@ -0,0 +1,252 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
use IteratorAggregate;
use RecursiveIteratorIterator;
use SplObjectStorage;
use function array_shift;
use function count;
use function current;
use function implode;
use function is_array;
use function spl_object_hash;
use function sprintf;
use function str_repeat;
use const PHP_EOL;
/**
* Exception for nested validations.
*
* This exception allows to have exceptions inside itself and providers methods
* to handle them and to retrieve nested messages based on itself and its
* children.
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Jonathan Stewmon <jstewmon@rmn.com>
* @author Wojciech Frącz <fraczwojciech@gmail.com>
*/
class NestedValidationException extends ValidationException implements IteratorAggregate
{
/**
* @var ValidationException[]
*/
private $exceptions = [];
/**
* Returns the exceptions that are children of the exception.
*
* @return ValidationException[]
*/
public function getChildren(): array
{
return $this->exceptions;
}
/**
* Adds a child to the exception.
*/
public function addChild(ValidationException $exception): self
{
$this->exceptions[spl_object_hash($exception)] = $exception;
return $this;
}
/**
* Adds children to the exception.
*
* @param ValidationException[] $exceptions
*/
public function addChildren(array $exceptions): self
{
foreach ($exceptions as $exception) {
$this->addChild($exception);
}
return $this;
}
public function getIterator(): SplObjectStorage
{
$childrenExceptions = new SplObjectStorage();
$recursiveIteratorIterator = $this->getRecursiveIterator();
$lastDepth = 0;
$lastDepthOriginal = 0;
$knownDepths = [];
foreach ($recursiveIteratorIterator as $childException) {
if ($this->isOmissible($childException)) {
continue;
}
$currentDepth = $lastDepth;
$currentDepthOriginal = $recursiveIteratorIterator->getDepth() + 1;
if (isset($knownDepths[$currentDepthOriginal])) {
$currentDepth = $knownDepths[$currentDepthOriginal];
} elseif ($currentDepthOriginal > $lastDepthOriginal) {
++$currentDepth;
}
if (!isset($knownDepths[$currentDepthOriginal])) {
$knownDepths[$currentDepthOriginal] = $currentDepth;
}
$lastDepth = $currentDepth;
$lastDepthOriginal = $currentDepthOriginal;
$childrenExceptions->attach($childException, $currentDepth);
}
return $childrenExceptions;
}
/**
* Returns a key->value array with all the messages of the exception.
*
* In this array the "keys" are the ids of the exceptions (defined name or
* name of the rule) and the values are the message.
*
* Once templates are passed it overwrites the templates of the given
* messages.
*
* @param string[]|string[][] $templates
*
* @return string[]
*/
public function getMessages(array $templates = []): array
{
$messages = [$this->getId() => $this->renderMessage($this, $templates)];
foreach ($this->getChildren() as $exception) {
$id = $exception->getId();
if (!$exception instanceof self) {
$messages[$id] = $this->renderMessage(
$exception,
$this->findTemplates($templates, $this->getId())
);
continue;
}
$messages[$id] = $exception->getMessages($this->findTemplates($templates, $id, $this->getId()));
if (count($messages[$id]) > 1) {
continue;
}
$messages[$id] = current($messages[$exception->getId()]);
}
if (count($messages) > 1) {
unset($messages[$this->getId()]);
}
return $messages;
}
/**
* Returns a string with all the messages of the exception.
*/
public function getFullMessage(): string
{
$messages = [];
$leveler = 1;
if (!$this->isOmissible($this)) {
$leveler = 0;
$messages[] = sprintf('- %s', $this->getMessage());
}
$exceptions = $this->getIterator();
/** @var ValidationException $exception */
foreach ($exceptions as $exception) {
$messages[] = sprintf(
'%s- %s',
str_repeat(' ', (int) ($exceptions[$exception] - $leveler) * 2),
$exception->getMessage()
);
}
return implode(PHP_EOL, $messages);
}
private function getRecursiveIterator(): RecursiveIteratorIterator
{
return new RecursiveIteratorIterator(
new RecursiveExceptionIterator($this),
RecursiveIteratorIterator::SELF_FIRST
);
}
private function isOmissible(Exception $exception): bool
{
if (!$exception instanceof self) {
return false;
}
if (count($exception->getChildren()) !== 1) {
return false;
}
/** @var ValidationException $childException */
$childException = current($exception->getChildren());
if ($childException->getMessage() === $exception->getMessage()) {
return true;
}
if ($exception->hasCustomTemplate()) {
return $childException->hasCustomTemplate();
}
return !$childException instanceof NonOmissibleException;
}
/**
* @param string[] $templates
*/
private function renderMessage(ValidationException $exception, array $templates): string
{
if (isset($templates[$exception->getId()])) {
$exception->updateTemplate($templates[$exception->getId()]);
}
return $exception->getMessage();
}
/**
* @param string[] $templates
* @param mixed ...$ids
*
* @return string[]
*/
private function findTemplates(array $templates, ...$ids): array
{
while (count($ids) > 0) {
$id = array_shift($ids);
if (!isset($templates[$id])) {
continue;
}
if (!is_array($templates[$id])) {
continue;
}
$templates = $templates[$id];
}
return $templates;
}
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Andrey Knupp Vital <andreykvital@gmail.com>
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class NfeAccessKeyException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的NFe访问密钥',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的NFe访问密钥',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Julián Gutiérrez <juliangut@gmail.com>
*/
final class NifException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是NIF',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是NIF',
],
];
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Tomasz Regdos <tomek@regdos.com>
*/
final class NipException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 必须是有效的波兰增值税标识号',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 不能是有效的波兰增值税标识号',
],
];
}
@@ -0,0 +1,32 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class NoException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 不被视为 "否"',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 被认为是 "否"',
],
];
}
@@ -0,0 +1,34 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Danilo Benevides <danilobenevides01@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class NoWhitespaceException extends ValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} 不能包含空格',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} 必须包含空格',
],
];
}
@@ -0,0 +1,22 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Andy Wendt <andy@awendt.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
interface NonOmissibleException extends Exception
{
}
@@ -0,0 +1,33 @@
<?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 file
* that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Exceptions;
/**
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class NoneOfException extends NestedValidationException
{
/**
* {@inheritDoc}
*/
protected $defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '这些规则都不能传递给 {{name}}',
],
self::MODE_NEGATIVE => [
self::STANDARD => '所有这些规则都必须传递给 {{name}}',
],
];
}

Some files were not shown because too many files have changed in this diff Show More