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