fix: ensure slug and excerpt are never null to pass validation
- Extract slug generation to separate variable before using in DTO - Convert null description to empty string for excerpt field - Prevents class-validator from rejecting null values - Fixes 'slug must be a string type' validation errors
This commit is contained in:
parent
a5008a3646
commit
3e61fe5694
@ -248,11 +248,15 @@ export class StrapiService {
|
||||
}
|
||||
}
|
||||
|
||||
// Generate slug if missing or null
|
||||
const slug =
|
||||
strapiArticle.slug || this.generateSlug(strapiArticle.title);
|
||||
|
||||
const articleData: Partial<CreateArticleDto> = {
|
||||
title: strapiArticle.title,
|
||||
excerpt: strapiArticle.description,
|
||||
excerpt: strapiArticle.description || '',
|
||||
content: strapiArticle.content,
|
||||
slug: strapiArticle.slug || this.generateSlug(strapiArticle.title),
|
||||
slug,
|
||||
status: strapiArticle.publishedAt
|
||||
? ArticleStatus.PUBLISHED
|
||||
: ArticleStatus.DRAFT,
|
||||
@ -335,11 +339,14 @@ export class StrapiService {
|
||||
}
|
||||
}
|
||||
|
||||
// Generate slug if missing or null
|
||||
const slug = strapiArticle.slug || this.generateSlug(strapiArticle.title);
|
||||
|
||||
const articleData: Partial<CreateArticleDto> = {
|
||||
title: strapiArticle.title,
|
||||
excerpt: strapiArticle.description,
|
||||
excerpt: strapiArticle.description || '',
|
||||
content: strapiArticle.content,
|
||||
slug: strapiArticle.slug || this.generateSlug(strapiArticle.title),
|
||||
slug,
|
||||
status,
|
||||
tags: [],
|
||||
featuredImage: imageUrl,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user