feat: improve attendance scheduling and API validation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { IsString, IsOptional, IsEnum, IsInt } from 'class-validator';
|
||||
import { IsBoolean, IsIn, IsInt, IsOptional, IsString } from 'class-validator';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
|
||||
export class CreateStudentDto {
|
||||
@IsString()
|
||||
@@ -82,6 +83,31 @@ export class UpdateStudentDto {
|
||||
supervisor?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(['active', 'graduated', 'withdrawn'])
|
||||
@IsIn(['active', 'graduated', 'withdrawn'])
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export class QueryStudentDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
name?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsIn(['active', 'graduated', 'withdrawn', 'archived'])
|
||||
status?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => {
|
||||
if (typeof value === 'boolean') return value;
|
||||
if (value === 'true' || value === '1') return true;
|
||||
if (value === 'false' || value === '0') return false;
|
||||
return value;
|
||||
})
|
||||
@IsBoolean()
|
||||
includeArchived?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
organizationId?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user