Skip to content

Commit 4902b18

Browse files
more validation
1 parent ddeee29 commit 4902b18

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/destination-actions/src/destinations/sendgrid/sendEmail/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const RESERVED_HEADERS = ["x-sg-id", "x-sg-eid", "received", "dkim-signat
22

33
export const MAX_CATEGORY_LENGTH = 255
44

5-
export const MAINIP_POOL_NAME_LENGTH = 2
5+
export const MIN_IP_POOL_NAME_LENGTH = 2
66

77
export const MAX_IP_POOL_NAME_LENGTH = 64
88

packages/destination-actions/src/destinations/sendgrid/sendEmail/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { RequestClient, PayloadValidationError } from '@segment/actions-core'
22
import type { Payload } from './generated-types'
33
import { sendEmailReq } from './types'
4-
import { RESERVED_HEADERS, MAX_CATEGORY_LENGTH } from './constants'
4+
import { RESERVED_HEADERS, MAX_CATEGORY_LENGTH, MIN_IP_POOL_NAME_LENGTH, MAX_IP_POOL_NAME_LENGTH } from './constants'
55

66
export async function send(request: RequestClient, payload: Payload) {
77
validate(payload)
@@ -86,5 +86,9 @@ function validate(payload: Payload){
8686
}
8787
}
8888

89+
if(payload.ipPoolName && (payload.ipPoolName.length >= MAX_IP_POOL_NAME_LENGTH || payload.ipPoolName.length <= MIN_IP_POOL_NAME_LENGTH)) {
90+
throw new PayloadValidationError(`IP Pool Name should at least ${MIN_IP_POOL_NAME_LENGTH} characters and at most ${MAX_IP_POOL_NAME_LENGTH} characters in length`)
91+
}
92+
8993
return
9094
}

0 commit comments

Comments
 (0)