mirror of
https://github.com/Respect/Validation.git
synced 2024-06-27 17:50:13 +02:00
Refactored interface declarations
This commit is contained in:
parent
df3533c9c8
commit
cb8edeccf6
|
@ -9,7 +9,7 @@ use Respect\Validation\Exceptions\ComponentException;
|
|||
use Respect\Validation\Exceptions\InvalidException;
|
||||
use Exception;
|
||||
|
||||
abstract class AbstractComposite extends AbstractRule implements Validatable
|
||||
abstract class AbstractComposite extends AbstractRule
|
||||
{
|
||||
|
||||
protected $rules = array();
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
abstract class AbstractRule
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
abstract class AbstractRule implements Validatable
|
||||
{
|
||||
|
||||
protected $messageTemplates = array();
|
||||
|
@ -36,4 +38,9 @@ abstract class AbstractRule
|
|||
return strval($mixed);
|
||||
}
|
||||
|
||||
public function __invoke($input)
|
||||
{
|
||||
return $this->validate($input);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,9 +3,8 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\InvalidException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
class All extends AbstractComposite implements Validatable
|
||||
class All extends AbstractComposite
|
||||
{
|
||||
|
||||
public function validate($input)
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Exceptions\NotAlphanumericException;
|
||||
|
||||
class Alnum extends AbstractRule implements Validatable
|
||||
class Alnum extends AbstractRule
|
||||
{
|
||||
const MSG_NOT_ALPHANUMERIC = 'Alnum_1';
|
||||
const MSG_NOT_ALPHANUMERIC_ADDITIONAL = 'Alnum_2';
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\InvalidException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
class AtLeast extends AbstractComposite implements Validatable
|
||||
class AtLeast extends AbstractComposite
|
||||
{
|
||||
|
||||
protected $howMany = 1;
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Exceptions\CallbackException;
|
||||
|
||||
class Callback extends AbstractRule implements Validatable
|
||||
class Callback extends AbstractRule
|
||||
{
|
||||
const MSG_CALLBACK = 'Callback_1';
|
||||
protected $messageTemplates = array(
|
||||
|
|
|
@ -4,9 +4,8 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Rules\AbstractDate;
|
||||
use Respect\Validation\Exceptions\InvalidDate;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
class Date extends AbstractDate implements Validatable
|
||||
class Date extends AbstractDate
|
||||
{
|
||||
const MSG_INVALID_DATE = 'Date_1';
|
||||
const MSG_INVALID_FORMAT = 'Date_2';
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Rules\AbstractDate;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Exceptions\DateOutOfBoundsException;
|
||||
use Respect\Validation\Exceptions\InvalidDate;
|
||||
use Respect\Validation\Validator;
|
||||
|
||||
class DateBetween extends AbstractDate implements Validatable
|
||||
class DateBetween extends AbstractDate
|
||||
{
|
||||
const MSG_OUT_OF_BOUNDS = 'DateBetween_1';
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Exceptions\AttributeNotPresentException;
|
||||
use Respect\Validation\Rules\All;
|
||||
|
||||
class HasAttribute extends All implements Validatable
|
||||
class HasAttribute extends All
|
||||
{
|
||||
const MSG_ATTRIBUTE_NOT_PRESENT = 'NullValue_1';
|
||||
protected $messageTemplates = array(
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\InvalidException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
class Most extends AbstractComposite implements Validatable
|
||||
class Most extends AbstractComposite
|
||||
{
|
||||
|
||||
public function assert($input)
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Exceptions\WhitespaceFoundException;
|
||||
|
||||
class NoWhitespace extends AbstractRule implements Validatable
|
||||
class NoWhitespace extends AbstractRule
|
||||
{
|
||||
const MSG_WHITESPACE_FOUND = 'NoWhitespace_1';
|
||||
protected $messageTemplates = array(
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\InvalidException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
class None extends AbstractComposite implements Validatable
|
||||
class None extends AbstractComposite
|
||||
{
|
||||
|
||||
public function validate($input)
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Exceptions\NotNullException;
|
||||
|
||||
class NullValue extends AbstractRule implements Validatable
|
||||
class NullValue extends AbstractRule
|
||||
{
|
||||
const MSG_NOT_NULL = 'NullValue_1';
|
||||
protected $messageTemplates = array(
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Exceptions\NotNumericException;
|
||||
|
||||
class Numeric extends AbstractRule implements Validatable
|
||||
class Numeric extends AbstractRule
|
||||
{
|
||||
const MSG_NOT_NUMERIC = 'Numeric_1';
|
||||
protected $messageTemplates = array(
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Exceptions\InvalidException;
|
||||
use Respect\Validation\Validatable;
|
||||
|
||||
class One extends AbstractComposite implements Validatable
|
||||
class One extends AbstractComposite
|
||||
{
|
||||
|
||||
public function assert($input)
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use ReflectionClass;
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Exceptions\CallbackException;
|
||||
use Respect\Validation\Exceptions\InvalidException;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
|
||||
class Sf extends AbstractRule implements Validatable
|
||||
class Sf extends AbstractRule
|
||||
{
|
||||
|
||||
protected $messages = array();
|
||||
|
|
|
@ -4,12 +4,11 @@ namespace Respect\Validation\Rules;
|
|||
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Exceptions\StringLengthException;
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Validator;
|
||||
use Respect\Validation\Exceptions\NotNumericException;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
class StringLength extends AbstractRule implements Validatable
|
||||
class StringLength extends AbstractRule
|
||||
{
|
||||
const MSG_LENGTH_MIN = 'StringLength_1';
|
||||
const MSG_LENGTH_MAX = 'StringLength_2';
|
||||
|
@ -25,15 +24,16 @@ class StringLength extends AbstractRule implements Validatable
|
|||
{
|
||||
$this->min = $min;
|
||||
$this->max = $max;
|
||||
$nullValue = Validator::NullValue();
|
||||
try {
|
||||
Validator::one(Validator::numeric($min), Validator::NullValue());
|
||||
Validator::one(Validator::numeric($min), $nullValue);
|
||||
} catch (NotNumericException $e) {
|
||||
throw new ComponentException(
|
||||
sprintf('%s is not a valid numeric length', $min)
|
||||
);
|
||||
}
|
||||
try {
|
||||
Validator::one(Validator::numeric($max), Validator::NullValue());
|
||||
Validator::one(Validator::numeric($max), $nullValue);
|
||||
} catch (NotNumericException $e) {
|
||||
throw new ComponentException(
|
||||
sprintf('%s is not a valid numeric length', $max)
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Exceptions\EmptyStringException;
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
|
||||
class StringNotEmpty extends AbstractRule implements Validatable
|
||||
class StringNotEmpty extends AbstractRule
|
||||
{
|
||||
const MSG_EMPTY_STRING = 'StringNotEmpty_1';
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use ReflectionClass;
|
||||
use Respect\Validation\Validatable;
|
||||
use Respect\Validation\Rules\AbstractRule;
|
||||
use Respect\Validation\Exceptions\CallbackException;
|
||||
use Respect\Validation\Exceptions\InvalidException;
|
||||
|
||||
class Zend extends AbstractRule implements Validatable
|
||||
class Zend extends AbstractRule
|
||||
{
|
||||
|
||||
protected $messages = array();
|
||||
|
|
Loading…
Reference in a new issue