Skip to content

Commit fa8738e

Browse files
committed
feat: public api valid extensions
1 parent ba2e22f commit fa8738e

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

apps/frontend/src/app/(app)/(site)/integrations/social/layout.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ export default async function IntegrationLayout({
88
const t = await getT();
99

1010
return (
11-
<div className="text-6xl text-center mt-[50px]">
12-
{t('adding_channel_redirecting_you', 'Adding channel, Redirecting You')}
13-
{children}
11+
<div className="bg-newBgColorInner p-[20px] flex flex-col transition-all flex-1">
12+
<div className="text-6xl text-center mt-[50px]">
13+
{t('adding_channel_redirecting_you', 'Adding channel, Redirecting You')}
14+
{children}
15+
</div>
1416
</div>
1517
);
1618
}
Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
import { ValidationArguments, ValidatorConstraintInterface, ValidatorConstraint } from "class-validator";
1+
import {
2+
ValidationArguments,
3+
ValidatorConstraintInterface,
4+
ValidatorConstraint,
5+
} from 'class-validator';
6+
7+
@ValidatorConstraint({ name: 'checkValidExtension', async: false })
8+
export class ValidUrlExtension implements ValidatorConstraintInterface {
9+
validate(text: string, args: ValidationArguments) {
10+
return (
11+
text.endsWith('.png') ||
12+
text.endsWith('.jpg') ||
13+
text.endsWith('.jpeg') ||
14+
text.endsWith('.gif') ||
15+
text.endsWith('.mp4')
16+
);
17+
}
18+
19+
defaultMessage(args: ValidationArguments) {
20+
// here you can provide default error message if validation failed
21+
return (
22+
'File must have a valid extension: .png, .jpg, .jpeg, .gif, or .mp4'
23+
);
24+
}
25+
}
226

327
@ValidatorConstraint({ name: 'checkValidPath', async: false })
428
export class ValidUrlPath implements ValidatorConstraintInterface {
@@ -7,11 +31,15 @@ export class ValidUrlPath implements ValidatorConstraintInterface {
731
return true;
832
}
933

10-
return (text || 'invalid url').indexOf(process.env.RESTRICT_UPLOAD_DOMAINS) > -1;
34+
return (
35+
(text || 'invalid url').indexOf(process.env.RESTRICT_UPLOAD_DOMAINS) > -1
36+
);
1137
}
1238

1339
defaultMessage(args: ValidationArguments) {
1440
// here you can provide default error message if validation failed
15-
return 'URL must contain the domain: ' + process.env.RESTRICT_UPLOAD_DOMAINS;
41+
return (
42+
'URL must contain the domain: ' + process.env.RESTRICT_UPLOAD_DOMAINS
43+
);
1644
}
17-
}
45+
}

libraries/nestjs-libraries/src/dtos/media/media.dto.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IsDefined, IsString, IsUrl, ValidateIf, Validate } from 'class-validator';
2-
import { ValidUrlPath } from '@gitroom/helpers/utils/valid.url.path';
2+
import { ValidUrlExtension, ValidUrlPath } from '@gitroom/helpers/utils/valid.url.path';
33

44
export class MediaDto {
55
@IsString()
@@ -9,6 +9,7 @@ export class MediaDto {
99
@IsString()
1010
@IsDefined()
1111
@Validate(ValidUrlPath)
12+
@Validate(ValidUrlExtension)
1213
path: string;
1314

1415
@ValidateIf((o) => o.alt)

0 commit comments

Comments
 (0)