My App
CourseKitBackend

DTOs & Validation

Data transfer objects with class-validator decorators and static validation

Overview

CourseKit provides DTO classes with class-validator decorators for request validation. Each DTO also has a static validate() method for manual validation without decorators.

UpdateEventDto

import { UpdateEventDto } from '@hfu.digital/coursekit-nestjs';
FieldTypeRequiredDescription
titlestringNoEvent title (non-empty)
startTimestring (ISO date)NoNew start time
durationMinnumberNoDuration in minutes (>= 1)
recurrenceRulestring | nullNoRRULE string or null
metadataRecord<string, unknown> | nullNoArbitrary metadata
courseIdstring | nullNoCourse reference
roomIdstring | nullNoRoom reference
periodIdstring | nullNoAcademic period reference
expectedVersionnumberNoFor optimistic concurrency

CreateExceptionDto

import { CreateExceptionDto } from '@hfu.digital/coursekit-nestjs';
FieldTypeRequiredDescription
eventIdstringYesParent event ID
originalDatestring (ISO date)YesWhich occurrence this overrides
type'cancelled' | 'modified' | 'added'YesException type
newStartTimestring | nullNoOverride start time (for modified/added)
newDurationMinnumber | nullNoOverride duration (>= 1)
newRoomIdstring | nullNoOverride room
metadataRecord<string, unknown> | nullNoOverride metadata

QueryFilterDto

import { QueryFilterDto } from '@hfu.digital/coursekit-nestjs';
FieldTypeRequiredDescription
dateRange{ start: string; end: string }YesDate range (start must be before end)
instructorIdsstring[]NoFilter by instructors
roomIdsstring[]NoFilter by rooms
groupIdsstring[]NoFilter by groups
courseIdsstring[]NoFilter by courses
periodIdstringNoFilter by academic period
tagsRecord<string, unknown>NoFilter by metadata tags

Entity DTOs

CreateRoomDto

FieldTypeRequiredDescription
namestringYesRoom name
buildingstring | nullNoBuilding name
campusstring | nullNoCampus name
capacitynumberYesSeat capacity (>= 0)
tagsRecord<string, unknown> | nullNoArbitrary tags

CreateInstructorDto

FieldTypeRequiredDescription
namestringYesInstructor name
emailstring | nullNoEmail address
tagsRecord<string, unknown> | nullNoArbitrary tags

CreateGroupDto

FieldTypeRequiredDescription
namestringYesGroup name
type'fixed' | 'enrollment'YesGroup type
maxCapacitynumber | nullNoMaximum capacity (>= 1)

CreateCourseDto

FieldTypeRequiredDescription
namestringYesCourse name
codestring | nullNoCourse code (e.g., 'CS101')
parentIdstring | nullNoParent course for hierarchy
metadataRecord<string, unknown> | nullNoArbitrary metadata

Static Validation

Each DTO has a static validate() method that returns a ValidationResult without requiring class-validator decorators:

const result = CreateExceptionDto.validate({
    eventId: 'event-1',
    originalDate: '2026-03-02',
    type: 'cancelled',
});

if (!result.valid) {
    console.log(result.errors);
    // [{ field: 'eventId', message: '...', value: '...' }]
}
interface ValidationResult {
    valid: boolean;
    errors: ValidationError[];
}

interface ValidationError {
    field: string;
    message: string;
    value?: unknown;
}

On this page