• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 9838430407

08 Jul 2024 11:06AM UTC coverage: 64.738% (-0.1%) from 64.857%
9838430407

push

github

web-flow
feat: deprecate query parameter validator (#6454)

51 of 60 new or added lines in 8 files covered. (85.0%)

34 existing lines in 10 files now uncovered.

11480 of 17733 relevant lines covered (64.74%)

68.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/ParameterValidator/Validator/Length.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\ParameterValidator\Validator;
15

16
/**
17
 * @deprecated use Parameter constraint instead
18
 */
19
final class Length implements ValidatorInterface
20
{
21
    use CheckFilterDeprecationsTrait;
22

23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function validate(string $name, array $filterDescription, array $queryParameters): array
27
    {
UNCOV
28
        $value = $queryParameters[$name] ?? null;
×
UNCOV
29
        if (empty($value) && '0' !== $value || !\is_string($value)) {
×
UNCOV
30
            return [];
×
31
        }
32

33
        $this->checkFilterDeprecations($filterDescription);
×
34

35
        $maxLength = $filterDescription['openapi']['maxLength'] ?? $filterDescription['swagger']['maxLength'] ?? null;
×
36
        $minLength = $filterDescription['openapi']['minLength'] ?? $filterDescription['swagger']['minLength'] ?? null;
×
37

38
        $errorList = [];
×
39

40
        if (null !== $maxLength && mb_strlen($value) > $maxLength) {
×
41
            $errorList[] = sprintf('Query parameter "%s" length must be lower than or equal to %s', $name, $maxLength);
×
42
        }
43

44
        if (null !== $minLength && mb_strlen($value) < $minLength) {
×
45
            $errorList[] = sprintf('Query parameter "%s" length must be greater than or equal to %s', $name, $minLength);
×
46
        }
47

48
        return $errorList;
×
49
    }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc