Skip to content

Commit

Permalink
N21-2309 Fix validation and add support for unknown schulconnex group…
Browse files Browse the repository at this point in the history
… roles (#5367)
  • Loading branch information
MarvinOehlerkingCap authored Dec 2, 2024
1 parent 7fff38c commit fcca17c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { IsArray, IsEnum, IsOptional } from 'class-validator';
import { SchulconnexGroupRole } from './schulconnex-group-role';
import { IsArray, IsOptional, IsString } from 'class-validator';

export class SchulconnexGruppenzugehoerigkeitResponse {
@IsOptional()
@IsArray()
@IsEnum(SchulconnexGroupRole, { each: true })
rollen?: SchulconnexGroupRole[];
@IsString({ each: true })
rollen?: string[];
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { IsArray, IsEnum, IsOptional, IsString } from 'class-validator';
import { SchulconnexGroupRole } from './schulconnex-group-role';
import { IsArray, IsOptional, IsString } from 'class-validator';

export class SchulconnexSonstigeGruppenzugehoerigeResponse {
@IsString()
ktid!: string;

@IsOptional()
@IsArray()
@IsEnum(SchulconnexGroupRole, { each: true })
rollen?: SchulconnexGroupRole[];
@IsString({ each: true })
rollen?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const RoleMapping: Record<SchulconnexRole, RoleName> = {
[SchulconnexRole.ORGADMIN]: RoleName.ADMINISTRATOR,
};

const GroupRoleMapping: Partial<Record<SchulconnexGroupRole, RoleName>> = {
const GroupRoleMapping: Partial<Record<SchulconnexGroupRole | string, RoleName>> = {
[SchulconnexGroupRole.TEACHER]: RoleName.TEACHER,
[SchulconnexGroupRole.STUDENT]: RoleName.STUDENT,
};
Expand Down Expand Up @@ -146,7 +146,7 @@ export class SchulconnexResponseMapper {
otherUsers = group.sonstige_gruppenzugehoerige
? group.sonstige_gruppenzugehoerige
.map((relation): ExternalGroupUserDto | null => this.mapToExternalGroupUser(relation))
.filter((otherUser: ExternalGroupUserDto | null) => otherUser !== null)
.filter((otherUser: ExternalGroupUserDto | null): otherUser is ExternalGroupUserDto => otherUser !== null)
: [];
}

Expand Down

0 comments on commit fcca17c

Please sign in to comment.