DTOs & Validation Data transfer objects with class-validator decorators and static validation
CourseKit provides DTO classes with class-validator decorators for request validation. Each DTO also has a static validate() method for manual validation without decorators.
import { UpdateEventDto } from '@hfu.digital/coursekit-nestjs' ;
Field Type Required Description titlestringNo Event title (non-empty) startTimestring (ISO date)No New start time durationMinnumberNo Duration in minutes (>= 1) recurrenceRulestring | nullNo RRULE string or null metadataRecord<string, unknown> | nullNo Arbitrary metadata courseIdstring | nullNo Course reference roomIdstring | nullNo Room reference periodIdstring | nullNo Academic period reference expectedVersionnumberNo For optimistic concurrency
import { CreateExceptionDto } from '@hfu.digital/coursekit-nestjs' ;
Field Type Required Description eventIdstringYes Parent event ID originalDatestring (ISO date)Yes Which occurrence this overrides type'cancelled' | 'modified' | 'added'Yes Exception type newStartTimestring | nullNo Override start time (for modified/added) newDurationMinnumber | nullNo Override duration (>= 1) newRoomIdstring | nullNo Override room metadataRecord<string, unknown> | nullNo Override metadata
import { QueryFilterDto } from '@hfu.digital/coursekit-nestjs' ;
Field Type Required Description dateRange{ start: string; end: string }Yes Date range (start must be before end) instructorIdsstring[]No Filter by instructors roomIdsstring[]No Filter by rooms groupIdsstring[]No Filter by groups courseIdsstring[]No Filter by courses periodIdstringNo Filter by academic period tagsRecord<string, unknown>No Filter by metadata tags
Field Type Required Description namestringYes Room name buildingstring | nullNo Building name campusstring | nullNo Campus name capacitynumberYes Seat capacity (>= 0) tagsRecord<string, unknown> | nullNo Arbitrary tags
Field Type Required Description namestringYes Instructor name emailstring | nullNo Email address tagsRecord<string, unknown> | nullNo Arbitrary tags
Field Type Required Description namestringYes Group name type'fixed' | 'enrollment'Yes Group type maxCapacitynumber | nullNo Maximum capacity (>= 1)
Field Type Required Description namestringYes Course name codestring | nullNo Course code (e.g., 'CS101') parentIdstring | nullNo Parent course for hierarchy metadataRecord<string, unknown> | nullNo Arbitrary metadata
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 ;
}