File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
packages/backend/src/apps/paysg/actions/create-payment-form-submission-subscription Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const action: IRawAction = {
5454 label : 'Payer Email' ,
5555 key : 'payer_email' ,
5656 type : 'string' as const ,
57- required : false ,
57+ required : true ,
5858 variables : true ,
5959 } ,
6060 {
Original file line number Diff line number Diff line change 1+ import emailValidator from 'email-validator'
12import { z } from 'zod'
23
34import { requestSchema as createPaymentFormSubmissionRequestSchema } from '../create-payment-form-submission/schema'
@@ -9,6 +10,21 @@ export const requestSchema = createPaymentFormSubmissionRequestSchema.extend({
910 . min ( 1 , { message : 'Specify a description' } )
1011 . max ( 500 , { message : 'Description cannot be more than 500 characters' } ) ,
1112 frequency : z . literal ( 'monthly' ) ,
13+ payer_email : z
14+ . string ( { invalid_type_error : 'Empty payer email' } )
15+ . trim ( )
16+ . max ( 255 , { message : 'Payer email cannot be more than 255 characters' } )
17+ . transform ( ( value , context ) => {
18+ if ( ! emailValidator . validate ( value ) ) {
19+ context . addIssue ( {
20+ code : z . ZodIssueCode . custom ,
21+ message : 'Invalid payer email' ,
22+ } )
23+ return z . NEVER
24+ }
25+
26+ return value
27+ } ) ,
1228 payer_address : z
1329 . string ( )
1430 . trim ( )
You can’t perform that action at this time.
0 commit comments