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