@@ -19,11 +19,44 @@ export class DTSConnectionCustomPromptStep<T extends IDTSConnectionWizardContext
19
19
return ! context . newDTSConnectionSettingValue ;
20
20
}
21
21
22
- private validateInput ( name : string | undefined ) : string | undefined {
23
- name = name ? name . trim ( ) : '' ;
24
- if ( ! validationUtils . hasValidCharLength ( name ) ) {
22
+ private validateInput ( connectionString : string | undefined ) : string | undefined {
23
+ connectionString = connectionString ? connectionString . trim ( ) : '' ;
24
+
25
+ // Check for basic character length validation
26
+ if ( ! validationUtils . hasValidCharLength ( connectionString ) ) {
25
27
return validationUtils . getInvalidCharLengthMessage ( ) ;
26
28
}
29
+
30
+ // Check if the connection string contains the required "Endpoint=" pattern
31
+ const endpointMatch = connectionString . match ( / E n d p o i n t = ( [ ^ ; ] + ) / ) ;
32
+ if ( ! endpointMatch ) {
33
+ return localize ( 'invalidDTSConnectionStringFormat' , 'DTS connection string must contain an "Endpoint=" parameter. Expected format: "Endpoint=<URL>;Authentication=<AuthType>"' ) ;
34
+ }
35
+
36
+ // Validate that the endpoint URL is properly formatted
37
+ const endpoint = endpointMatch [ 1 ] ;
38
+ try {
39
+ const url = new URL ( endpoint ) ;
40
+ // Ensure it's using a valid protocol
41
+ if ( ! [ 'http:' , 'https:' ] . includes ( url . protocol ) ) {
42
+ return localize ( 'invalidDTSEndpointProtocol' , 'DTS endpoint must use HTTP or HTTPS protocol. Found: {0}' , url . protocol ) ;
43
+ }
44
+ } catch ( error ) {
45
+ return localize ( 'invalidDTSEndpointURL' , 'DTS endpoint is not a valid URL: {0}' , endpoint ) ;
46
+ }
47
+
48
+ // Check if the connection string contains an Authentication parameter with a non-empty value
49
+ const authMatch = connectionString . match ( / A u t h e n t i c a t i o n = ( [ ^ ; ] * ) / ) ;
50
+ if ( ! authMatch ) {
51
+ return localize ( 'missingDTSAuthentication' , 'DTS connection string must contain an "Authentication=" parameter. Expected format: "Endpoint=<URL>;Authentication=<AuthType>"' ) ;
52
+ }
53
+
54
+ // Validate that the Authentication parameter has a non-empty value
55
+ const authValue = authMatch [ 1 ] ;
56
+ if ( ! authValue || authValue . trim ( ) === '' ) {
57
+ return localize ( 'emptyDTSAuthentication' , 'DTS Authentication parameter cannot be empty. Expected format: "Endpoint=<URL>;Authentication=<AuthType>"' ) ;
58
+ }
59
+
27
60
return undefined ;
28
61
}
29
62
}
0 commit comments