@@ -123,15 +123,31 @@ const clientCertificateDetailsSchema = object({
123123 } ,
124124) ;
125125
126+ const forbiddenCustomHeaderNames = [
127+ 'content-type' ,
128+ 'encoding' ,
129+ 'authorization' ,
130+ 'host' ,
131+ 'akamai' ,
132+ ] ;
133+
126134const customHeaderSchema = object ( {
127135 name : string ( )
128136 . max ( maxLength , maxLengthMessage )
129- . required ( 'Custom Header Name is required.' ) ,
137+ . required ( 'Custom Header Name is required.' )
138+ . test (
139+ 'forbidden-custom-header-name' ,
140+ 'This header name is not allowed.' ,
141+ ( value ) =>
142+ ! forbiddenCustomHeaderNames . includes ( value . trim ( ) . toLowerCase ( ) ) ,
143+ ) ,
130144 value : string ( )
131145 . max ( maxLength , maxLengthMessage )
132- . required ( 'Custom Header Value is required' ) ,
146+ . required ( 'Custom Header Value is required. ' ) ,
133147} ) ;
134148
149+ const urlRgx = / ^ ( h t t p s ? : \/ \/ ) ? ( w w w \. ) ? [ a - z A - Z 0 - 9 - ] + ( \. [ a - z A - Z ] + ) + ( \/ \S * ) ? $ / ;
150+
135151const customHTTPSDetailsSchema = object ( {
136152 authentication : authenticationSchema . required ( ) ,
137153 client_certificate_details : clientCertificateDetailsSchema . optional ( ) ,
@@ -143,7 +159,10 @@ const customHTTPSDetailsSchema = object({
143159 data_compression : string ( ) . oneOf ( [ 'gzip' , 'None' ] ) . required ( ) ,
144160 endpoint_url : string ( )
145161 . max ( maxLength , maxLengthMessage )
146- . required ( 'Endpoint URL is required.' ) ,
162+ . required ( 'Endpoint URL is required.' )
163+ . test ( 'is-valid-url' , 'Endpoint URL must be a valid URL.' , ( value ) =>
164+ urlRgx . test ( value ) ,
165+ ) ,
147166} ) ;
148167
149168const hostRgx =
@@ -298,7 +317,7 @@ const detailsShouldNotExistOrBeNull = (schema: MixedSchema) =>
298317
299318const streamSchemaBase = object ( {
300319 label : string ( )
301- . min ( 3 , 'Stream name must have at least 3 characters' )
320+ . min ( 3 , 'Stream name must have at least 3 characters. ' )
302321 . max ( maxLength , maxLengthMessage )
303322 . required ( 'Stream name is required.' ) ,
304323 status : mixed < 'active' | 'inactive' | 'provisioning' > ( ) . oneOf ( [
@@ -338,7 +357,7 @@ export const updateStreamSchema = streamSchemaBase
338357 return detailsShouldNotExistOrBeNull ( mixed ( ) ) ;
339358 } ) ,
340359 } )
341- . noUnknown ( 'Object contains unknown fields' ) ;
360+ . noUnknown ( 'Object contains unknown fields. ' ) ;
342361
343362export const streamAndDestinationFormSchema = object ( {
344363 stream : streamSchemaBase . shape ( {
@@ -349,7 +368,7 @@ export const streamAndDestinationFormSchema = object({
349368 otherwise : ( schema ) =>
350369 schema
351370 . nullable ( )
352- . equals ( [ null ] , 'Details must be null for audit_logs type' ) ,
371+ . equals ( [ null ] , 'Details must be null for audit_logs type. ' ) ,
353372 } ) as Schema < InferType < typeof streamDetailsSchema > | null > ,
354373 } ) ,
355374 destination : destinationFormSchema . defined ( ) . when ( 'stream.destinations' , {
0 commit comments