Skip to content

PM-571 Validate data in create copilot request endpoint #778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
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
72 changes: 72 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5499,6 +5499,78 @@ definitions:
data:
type: object
description: copilot request data
required:
- projectId
- complexity
- requiresCommunication
- paymentType
- projectType
- overview
- skills
- startDate
- numWeeks
- tzRestrictions
- numHoursPerWeek
properties:
projectId:
type: number
description: The ID of the project
copilotUsername:
type: string
description: The username of the copilot (if applicable)
existingCopilot:
type: string
enum: [yes, no]
description: Indicates if an existing copilot is assigned
complexity:
type: string
enum: [low, medium, high]
description: Complexity level of the copilot request
requiresCommunication:
type: string
enum: [yes, no]
description: Whether the request requires communication
paymentType:
type: string
enum: [standard, other]
description: Payment type for the copilot
otherPaymentType:
type: string
nullable: true
description: If `paymentType` is "other", specify additional details
projectType:
type: string
description: Type of project
overview:
type: string
minLength: 10
description: Overview of the copilot request
skills:
type: array
description: List of required skills
items:
type: object
properties:
id:
type: string
description: Skill ID
name:
type: string
description: Skill name
minItems: 1
startDate:
type: string
format: date
description: Start date for the copilot
numWeeks:
type: integer
description: Duration for which copilot is needed
tzRestrictions:
type: string
description: Timezone restrictions (if any)
numHoursPerWeek:
type: integer
description: Expected hours per week
NewProject:
type: object
required:
Expand Down
23 changes: 22 additions & 1 deletion src/routes/copilotRequest/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,28 @@ import { Op } from 'sequelize';

const addCopilotRequestValidations = {
body: Joi.object().keys({
data: Joi.object().required(),
data: Joi.object()
.keys({
projectId: Joi.number().required(),
copilotUsername: Joi.string(),
complexity: Joi.string().valid('low', 'medium', 'high').required(),
requiresCommunication: Joi.string().valid('yes', 'no').required(),
paymentType: Joi.string().valid('standard', 'other').required(),
otherPaymentType: Joi.string(),
projectType: Joi.string().required(),
overview: Joi.string().min(10).required(),
skills: Joi.array().items(
Joi.object({
id: Joi.string().required(),
name: Joi.string().required(),
})
).min(1).required(),
startDate: Joi.date().iso().required(),
numWeeks: Joi.number().integer().positive().required(),
tzRestrictions: Joi.string().required(),
numHoursPerWeek: Joi.number().integer().positive().required(),
})
.required(),
}),
};

Expand Down