1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Movies\Request; |
4
|
|
|
|
5
|
|
|
use App\Movies\Entity\Movie; |
6
|
|
|
use App\Movies\Entity\MovieTMDB; |
7
|
|
|
use App\Movies\Entity\MovieTranslations; |
8
|
|
|
use App\Movies\Validation\MovieTranslationRules; |
9
|
|
|
use App\Request\BaseRequest; |
10
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
11
|
|
|
|
12
|
|
|
class CreateMovieRequest extends BaseRequest |
13
|
|
|
{ |
14
|
3 |
|
public function rules() |
15
|
|
|
{ |
16
|
3 |
|
return new Assert\Collection([ |
17
|
3 |
|
'movie' => new Assert\Collection([ |
18
|
|
|
// Movie |
19
|
3 |
|
'originalTitle' => [new Assert\NotBlank(), new Assert\Length(['min' => 2, 'max' => 100])], |
20
|
3 |
|
'originalPosterUrl' => [new Assert\NotBlank(), new Assert\Length(['min' => 10, 'max' => 255])], |
21
|
3 |
|
'imdbId' => new Assert\Length(['min' => 5, 'max' => 20]), |
22
|
3 |
|
'runtime' => new Assert\Type(['type' => 'integer']), |
23
|
3 |
|
'budget' => new Assert\Type(['type' => 'integer']), |
24
|
3 |
|
'releaseDate' => new Assert\Date(), |
25
|
|
|
// MovieTranslations[] |
26
|
3 |
|
'translations' => $this->eachItemValidation( |
27
|
3 |
|
MovieTranslationRules::getDefaultRules() |
28
|
|
|
), |
29
|
3 |
|
'genres' => $this->eachItemValidation([ |
30
|
3 |
|
'id' => [new Assert\NotBlank(), new Assert\Type('integer')], |
31
|
|
|
]), |
32
|
|
|
// MovieTMDB |
33
|
3 |
|
'tmdb' => new Assert\Collection([ |
34
|
3 |
|
'id' => [new Assert\NotBlank(), new Assert\Type(['type' => 'integer'])], |
35
|
3 |
|
'voteAverage' => new Assert\Range(['min' => 0.0, 'max' => 10.0]), |
36
|
3 |
|
'voteCount' => new Assert\Type(['type' => 'integer']), |
37
|
|
|
]), |
38
|
|
|
]), |
39
|
|
|
]); |
40
|
|
|
} |
41
|
|
|
} |