Thank you for stopping by for help. I have API woring on using NodeJs, It has 3 arguments It accepts, but It seems like there is an issue on validation. When I call the API, It gives me this result,
[{
"statusCode": 400,
"message": [
"an unknown value was passed to the validate function"
],
"error": "Bad Request"
}]
Help me anyone can tell what's wrong with this!
I put three arguments, in order of,
https://www.youtube.com/watch?v=C5Y3fpHg45U1JP
and there goes my code
/**
* Gets Subtitle From Youtube
* @param getYoutubeSubtitleDto
*/
public async getSubtitle(
getYoutubeSubtitleDto: GetYoutubeSubtitleDto,
): Promise<Subtitle[]> {
const { videoId, lang, projectId } = getYoutubeSubtitleDto
return this.getOrCreateSubtitles(videoId, lang, projectId)
}
export class GetYoutubeSubtitleDto extends Video {
@ApiProperty()
@IsNumber()
@Type(() => Number)
projectId: number
@ApiProperty({ description: 'Translation Language' })
@IsString()
lang: string
}
export const YOUTUBE_LINK_REGEX = /http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?/
export class Video {
@ApiProperty({ description: 'Youtube Link' })
@IsString()
@Matches(YOUTUBE_LINK_REGEX)
video: string
public get videoId(): string {
return YOUTUBE_LINK_REGEX.exec(this.video)[1]
}
}