Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions src/lib/forms-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,26 +311,6 @@ const entraApplicationEntitySchema = Joi.object().keys({
displayName: Joi.string().required(),
})

const entraApplicationFolderPathSchema = Joi.string()
.custom((value, helpers) => {
if (typeof value === 'string') {
if (!value.startsWith('/')) {
return helpers.error('string.startsWithSlash')
}
if (value.endsWith('/')) {
return helpers.error('string.endsWithSlash')
}
}

return value
})
.messages({
'string.startsWithSlash':
'{{#label}} must start with a forward slash ("/")',
'string.endsWithSlash':
'{{#label}} must not end with a forward slash ("/")',
})

export const WorkflowEventSchema = Joi.object().keys({
type: Joi.string()
.required()
Expand Down Expand Up @@ -521,7 +501,25 @@ export const WorkflowEventSchema = Joi.object().keys({
...entraApplicationKeys,
sharepointSite: entraApplicationEntitySchema.required(),
sharepointDrive: entraApplicationEntitySchema.required(),
folderPath: entraApplicationFolderPathSchema,
folderPath: Joi.string()
.custom((value, helpers) => {
if (typeof value === 'string') {
if (!value.startsWith('/')) {
return helpers.error('string.startsWithSlash')
}
if (value.endsWith('/')) {
return helpers.error('string.endsWithSlash')
}
}

return value
})
.messages({
'string.startsWithSlash':
'{{#label}} must start with a forward slash ("/")',
'string.endsWithSlash':
'{{#label}} must not end with a forward slash ("/")',
}),
excludeAttachments: Joi.boolean().default(false),
...pdfSubmissionEventConfiguration,
}),
Expand All @@ -530,9 +528,8 @@ export const WorkflowEventSchema = Joi.object().keys({
is: 'EXCEL_ADD_ROW',
then: Joi.object().keys({
...entraApplicationKeys,
site: entraApplicationFolderPathSchema.required(),
drive: entraApplicationFolderPathSchema.required(),
folderPath: entraApplicationFolderPathSchema.required(),
site: entraApplicationEntitySchema.required(),
drive: entraApplicationEntitySchema.required(),
excelFile: entraApplicationEntitySchema.required(),
table: entraApplicationEntitySchema.required(),
mapping: Joi.array()
Expand Down