forked from hangshuo652/aurak
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user