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