@@ 30-56 (lines=27) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class NumericLessOrEquals extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param mixed $value |
|
34 | */ |
|
35 | public function __construct($value) |
|
36 | { |
|
37 | assert(is_numeric($value) === true); |
|
38 | parent::__construct( |
|
39 | $value, |
|
40 | ErrorCodes::NUMERIC_LESS_OR_EQUALS, |
|
41 | Messages::NUMERIC_LESS_OR_EQUALS, |
|
42 | [$value] |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @inheritdoc |
|
48 | */ |
|
49 | public static function compare($value, ContextInterface $context): bool |
|
50 | { |
|
51 | assert(is_numeric($value) === true); |
|
52 | $result = is_numeric($value) === true && $value <= static::readValue($context); |
|
53 | ||
54 | return $result; |
|
55 | } |
|
56 | } |
|
57 |
@@ 30-56 (lines=27) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class NumericLessThan extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param mixed $value |
|
34 | */ |
|
35 | public function __construct($value) |
|
36 | { |
|
37 | assert(is_numeric($value) === true); |
|
38 | parent::__construct( |
|
39 | $value, |
|
40 | ErrorCodes::NUMERIC_LESS_THAN, |
|
41 | Messages::NUMERIC_LESS_THAN, |
|
42 | [$value] |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @inheritdoc |
|
48 | */ |
|
49 | public static function compare($value, ContextInterface $context): bool |
|
50 | { |
|
51 | assert(is_numeric($value) === true); |
|
52 | $result = is_numeric($value) === true && $value < static::readValue($context); |
|
53 | ||
54 | return $result; |
|
55 | } |
|
56 | } |
|
57 |
@@ 30-56 (lines=27) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class NumericMoreOrEqualsThan extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param mixed $value |
|
34 | */ |
|
35 | public function __construct($value) |
|
36 | { |
|
37 | assert(is_numeric($value) === true); |
|
38 | parent::__construct( |
|
39 | $value, |
|
40 | ErrorCodes::NUMERIC_MORE_OR_EQUALS, |
|
41 | Messages::NUMERIC_MORE_OR_EQUALS, |
|
42 | [$value] |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @inheritdoc |
|
48 | */ |
|
49 | public static function compare($value, ContextInterface $context): bool |
|
50 | { |
|
51 | assert(is_numeric($value) === true); |
|
52 | $result = is_numeric($value) === true && static::readValue($context) <= $value; |
|
53 | ||
54 | return $result; |
|
55 | } |
|
56 | } |
|
57 |
@@ 30-56 (lines=27) @@ | ||
27 | /** |
|
28 | * @package Limoncello\Validation |
|
29 | */ |
|
30 | final class NumericMoreThan extends BaseOneValueComparision |
|
31 | { |
|
32 | /** |
|
33 | * @param mixed $value |
|
34 | */ |
|
35 | public function __construct($value) |
|
36 | { |
|
37 | assert(is_numeric($value) === true); |
|
38 | parent::__construct( |
|
39 | $value, |
|
40 | ErrorCodes::NUMERIC_MORE_THAN, |
|
41 | Messages::NUMERIC_MORE_THAN, |
|
42 | [$value] |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @inheritdoc |
|
48 | */ |
|
49 | public static function compare($value, ContextInterface $context): bool |
|
50 | { |
|
51 | assert(is_numeric($value) === true); |
|
52 | $result = is_numeric($value) === true && static::readValue($context) < $value; |
|
53 | ||
54 | return $result; |
|
55 | } |
|
56 | } |
|
57 |
@@ 31-56 (lines=26) @@ | ||
28 | /** |
|
29 | * @package Limoncello\Validation |
|
30 | */ |
|
31 | final class StringLengthMax extends BaseOneValueComparision |
|
32 | { |
|
33 | /** |
|
34 | * @param int $max |
|
35 | */ |
|
36 | public function __construct(int $max) |
|
37 | { |
|
38 | parent::__construct( |
|
39 | $max, |
|
40 | ErrorCodes::STRING_LENGTH_MAX, |
|
41 | Messages::STRING_LENGTH_MAX, |
|
42 | [$max] |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @inheritdoc |
|
48 | */ |
|
49 | public static function compare($value, ContextInterface $context): bool |
|
50 | { |
|
51 | assert(is_string($value) === true); |
|
52 | $result = is_string($value) === true && strlen($value) <= static::readValue($context); |
|
53 | ||
54 | return $result; |
|
55 | } |
|
56 | } |
|
57 |
@@ 31-56 (lines=26) @@ | ||
28 | /** |
|
29 | * @package Limoncello\Validation |
|
30 | */ |
|
31 | final class StringLengthMin extends BaseOneValueComparision |
|
32 | { |
|
33 | /** |
|
34 | * @param int $min |
|
35 | */ |
|
36 | public function __construct(int $min) |
|
37 | { |
|
38 | parent::__construct( |
|
39 | $min, |
|
40 | ErrorCodes::STRING_LENGTH_MIN, |
|
41 | Messages::STRING_LENGTH_MIN, |
|
42 | [$min] |
|
43 | ); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @inheritdoc |
|
48 | */ |
|
49 | public static function compare($value, ContextInterface $context): bool |
|
50 | { |
|
51 | assert(is_string($value) === true); |
|
52 | $result = is_string($value) === true && static::readValue($context) <= strlen($value); |
|
53 | ||
54 | return $result; |
|
55 | } |
|
56 | } |
|
57 |
@@ 31-57 (lines=27) @@ | ||
28 | /** |
|
29 | * @package Limoncello\Validation |
|
30 | */ |
|
31 | final class StringRegExp extends BaseOneValueComparision |
|
32 | { |
|
33 | /** |
|
34 | * @param mixed $pattern |
|
35 | */ |
|
36 | public function __construct($pattern) |
|
37 | { |
|
38 | assert(is_string($pattern) === true); |
|
39 | parent::__construct( |
|
40 | $pattern, |
|
41 | ErrorCodes::STRING_REG_EXP, |
|
42 | Messages::STRING_REG_EXP, |
|
43 | [$pattern] |
|
44 | ); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * @inheritdoc |
|
49 | */ |
|
50 | public static function compare($value, ContextInterface $context): bool |
|
51 | { |
|
52 | assert(is_string($value) === true); |
|
53 | $result = is_string($value) === true && preg_match(static::readValue($context), $value) === 1; |
|
54 | ||
55 | return $result; |
|
56 | } |
|
57 | } |
|
58 |