Skip to content

Commit 3d15329

Browse files
committed
feat: throw unprocessable exception if data does not pass schema validation
1 parent db4673b commit 3d15329

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

apps/api/src/instrument-records/instrument-records.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ export class InstrumentRecordsService {
6565

6666
await this.subjectsService.findById(subjectId);
6767
await this.sessionsService.findById(sessionId);
68-
68+
if (!instrument.validationSchema.safeParse(data).success) {
69+
throw new UnprocessableEntityException(
70+
`Data received does not pass validation schema of instrument '${instrument.id}'`
71+
);
72+
}
6973
return this.instrumentRecordModel.create({
7074
data: {
7175
computedMeasures: instrument.measures

0 commit comments

Comments
 (0)