fix: linkedGroupIds null check in validateRequiredFields

null !== undefined was true, causing false validation failure on templates
without linked groups. Changed to != null check.
This commit is contained in:
Developer
2026-05-21 11:17:45 +08:00
parent 54762ca299
commit 240aea24aa
5 changed files with 27 additions and 25 deletions
@@ -20,16 +20,16 @@ export class TemplateService {
) {}
private validateRequiredFields(data: {
linkedGroupIds?: string[];
dimensions?: Array<{ name: string; label?: string; weight?: number }>;
linkedGroupIds?: string[] | null;
dimensions?: Array<{ name: string; label?: string; weight?: number }> | null;
}) {
if (data.linkedGroupIds !== undefined) {
if (!Array.isArray(data.linkedGroupIds) || data.linkedGroupIds.length === 0) {
if (data.linkedGroupIds != null && Array.isArray(data.linkedGroupIds)) {
if (data.linkedGroupIds.length === 0) {
throw new BadRequestException('At least one knowledge group must be linked');
}
}
if (data.dimensions !== undefined) {
if (!Array.isArray(data.dimensions) || data.dimensions.length === 0) {
if (data.dimensions != null && Array.isArray(data.dimensions)) {
if (data.dimensions.length === 0) {
throw new BadRequestException('At least one dimension must be defined');
}
for (const d of data.dimensions) {