mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[API] Apply statistics constraints sequentially to fix 500 error when using an undefined parameter
This commit is contained in:
parent
d37c6a8947
commit
5969f0aa1d
2 changed files with 14 additions and 28 deletions
|
|
@ -90,19 +90,21 @@ final class GetStatisticsAction
|
|||
private function createInputDataConstraints(): array
|
||||
{
|
||||
return [
|
||||
new SymfonyConstraints\Collection([
|
||||
'channelCode' => new Constraints\Code(),
|
||||
'startDate' => [
|
||||
new SymfonyConstraints\NotBlank(),
|
||||
new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'),
|
||||
],
|
||||
'interval' => new SymfonyConstraints\Choice(choices: array_keys($this->intervalsMap), multiple: false),
|
||||
'endDate' => [
|
||||
new SymfonyConstraints\NotBlank(),
|
||||
new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'),
|
||||
],
|
||||
new SymfonyConstraints\Sequentially([
|
||||
new SymfonyConstraints\Collection([
|
||||
'channelCode' => new Constraints\Code(),
|
||||
'startDate' => [
|
||||
new SymfonyConstraints\NotBlank(),
|
||||
new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'),
|
||||
],
|
||||
'interval' => new SymfonyConstraints\Choice(choices: array_keys($this->intervalsMap), multiple: false),
|
||||
'endDate' => [
|
||||
new SymfonyConstraints\NotBlank(),
|
||||
new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'),
|
||||
],
|
||||
]),
|
||||
new SymfonyConstraints\Expression(expression: 'value["startDate"] < value["endDate"]', message: 'sylius.statistics.end_date.invalid'),
|
||||
]),
|
||||
new SymfonyConstraints\Expression(expression: 'value["startDate"] < value["endDate"]', message: 'sylius.statistics.end_date.invalid'),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,10 +262,6 @@ final class StatisticsTest extends JsonApiTestCase
|
|||
'propertyPath' => '[endDate]',
|
||||
'message' => 'This field is missing.',
|
||||
],
|
||||
[
|
||||
'propertyPath' => '',
|
||||
'message' => 'The start date must be earlier than the end date.',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
|
@ -288,10 +284,6 @@ final class StatisticsTest extends JsonApiTestCase
|
|||
'propertyPath' => '[endDate]',
|
||||
'message' => 'This field is missing.',
|
||||
],
|
||||
[
|
||||
'propertyPath' => '',
|
||||
'message' => 'The start date must be earlier than the end date.',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -355,10 +347,6 @@ final class StatisticsTest extends JsonApiTestCase
|
|||
'propertyPath' => '[endDate]',
|
||||
'message' => 'This value should not be blank.',
|
||||
],
|
||||
[
|
||||
'propertyPath' => '',
|
||||
'message' => 'The start date must be earlier than the end date.',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -392,10 +380,6 @@ final class StatisticsTest extends JsonApiTestCase
|
|||
'propertyPath' => '[startDate]',
|
||||
'message' => 'The date time is not valid ISO 8601 date time in Y-m-d\TH:i:s format.',
|
||||
],
|
||||
[
|
||||
'propertyPath' => '',
|
||||
'message' => 'The start date must be earlier than the end date.',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue