5
5
use App \Repository \BandRepository ;
6
6
use Doctrine \DBAL \Types \Types ;
7
7
use Doctrine \ORM \Mapping as ORM ;
8
+ use Symfony \Component \Validator \Constraints as Assert ;
8
9
9
10
#[ORM \Entity(repositoryClass: BandRepository::class)]
10
11
class Band
@@ -15,24 +16,34 @@ class Band
15
16
private ?int $ id = null ;
16
17
17
18
#[ORM \Column(length: 30 )]
19
+ #[Assert \NotBlank(message: 'Name is required. ' , groups: ['create ' ])]
18
20
private ?string $ name = null ;
19
21
20
22
#[ORM \Column(length: 30 )]
23
+ #[Assert \NotBlank(message: 'Origin is required. ' , groups: ['create ' ])]
21
24
private ?string $ origin = null ;
22
25
23
26
#[ORM \Column(length: 30 )]
27
+ #[Assert \NotBlank(message: 'City is required. ' , groups: ['create ' ])]
24
28
private ?string $ city = null ;
25
29
26
30
#[ORM \Column(type: Types::SMALLINT )]
31
+ #[Assert \NotBlank(message: 'Start year is required. ' , groups: ['create ' ])]
32
+ #[Assert \Type(type: 'integer ' , message: 'Start year must be an integer. ' )]
33
+ #[Assert \Range(notInRangeMessage: 'Start year must be between 1900 and 2100. ' , min: 1900 , max: 2100 )]
27
34
private ?int $ startYear = null ;
28
35
29
36
#[ORM \Column(type: Types::SMALLINT , nullable: true )]
37
+ #[Assert \Type(type: 'integer ' , message: 'Separation year must be an integer. ' )]
38
+ #[Assert \Range(notInRangeMessage: 'Separation year must be between 1900 and 2100. ' , min: 1900 , max: 2100 )]
30
39
private ?int $ separationYear = null ;
31
40
32
41
#[ORM \Column(length: 255 , nullable: true )]
33
42
private ?string $ founders = null ;
34
43
35
44
#[ORM \Column(type: Types::SMALLINT , nullable: true )]
45
+ #[Assert \Type(type: 'integer ' , message: 'Members must be an integer. ' )]
46
+ #[Assert \Range(notInRangeMessage: 'Members must be between 1 and 50. ' , min: 1 , max: 50 )]
36
47
private ?int $ members = null ;
37
48
38
49
#[ORM \Column(length: 30 , nullable: true )]
0 commit comments