@@ -21,6 +21,14 @@ class Phone extends Constraint
2121 public const PHONE_NUMBER_NOT_EXIST = 'f32ef12d-cefa-42d9-97f0-520d90276bf0 ' ;
2222 public const INVALID_COUNTRY_CODE = '5530a448-f887-48c0-8ef8-77f206aa52b6 ' ;
2323
24+ public string $ message = 'The value {{ value }} is not a valid phone number. ' ;
25+ public string $ notIntlFormatMessage = 'The value {{ value }} is not formatted as an international phone number. ' ;
26+ public string $ tooShortMessage = 'The phone number {{ value }} is too short. ' ;
27+ public string $ tooLongMessage = 'The phone number {{ value }} is too long. ' ;
28+ public string $ inexistantMessage = 'The phone number {{ value }} does not exist. ' ;
29+ public string $ wrongTypeMessage = 'The value {{ value }} is not an accepted phone number type. ' ;
30+ public string $ invalidCountryCodeMessage = 'The phone number {{ value }} does not have a valid country code. ' ;
31+
2432 /**
2533 * @return array<int>
2634 */
@@ -41,13 +49,27 @@ public function getValidTypes(): array
4149 ];
4250 }
4351
44- public string $ message = 'The value {{ value }} is not a valid phone number. ' ;
45- public string $ notIntlFormatMessage = 'The value {{ value }} is not formatted as an international phone number. ' ;
46- public string $ tooShortMessage = 'The phone number {{ value }} is too short. ' ;
47- public string $ tooLongMessage = 'The phone number {{ value }} is too long. ' ;
48- public string $ inexistantMessage = 'The phone number {{ value }} does not exist. ' ;
49- public string $ wrongTypeMessage = 'The value {{ value }} is not an accepted phone number type. ' ;
50- public string $ invalidCountryCodeMessage = 'The phone number {{ value }} does not have a valid country code. ' ;
52+ public function __construct (
53+ ?string $ message = null ,
54+ ?string $ notIntlFormatMessage = null ,
55+ ?string $ tooShortMessage = null ,
56+ ?string $ tooLongMessage = null ,
57+ ?string $ inexistantMessage = null ,
58+ ?string $ wrongTypeMessage = null ,
59+ ?string $ invalidCountryCodeMessage = null ,
60+ ?array $ groups = null ,
61+ mixed $ payload = null ,
62+ ) {
63+ parent ::__construct ([], $ groups , $ payload );
64+
65+ $ this ->message = $ message ?? $ this ->message ;
66+ $ this ->notIntlFormatMessage = $ notIntlFormatMessage ?? $ this ->notIntlFormatMessage ;
67+ $ this ->tooShortMessage = $ tooShortMessage ?? $ this ->tooShortMessage ;
68+ $ this ->tooLongMessage = $ tooLongMessage ?? $ this ->tooLongMessage ;
69+ $ this ->inexistantMessage = $ inexistantMessage ?? $ this ->inexistantMessage ;
70+ $ this ->wrongTypeMessage = $ wrongTypeMessage ?? $ this ->wrongTypeMessage ;
71+ $ this ->invalidCountryCodeMessage = $ invalidCountryCodeMessage ?? $ this ->invalidCountryCodeMessage ;
72+ }
5173
5274 /**
5375 * {@inheritDoc}
0 commit comments