feat: unify drainage targets and carrier status UI
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { ClientBatchTaskDto, ClientDeleteResourceDto, ClientImportConfirmDto } from './client-write.dto';
|
||||
import { ClientBatchTaskDto, ClientDeleteResourceDto, ClientDrainageInfoDto, ClientImportConfirmDto } from './client-write.dto';
|
||||
import { strictValidationPipe } from './strict-validation.pipe';
|
||||
|
||||
function validate<T>(metatype: new () => T, value: unknown) {
|
||||
@@ -45,4 +45,18 @@ describe('strict client write DTOs', () => {
|
||||
}),
|
||||
).rejects.toBeInstanceOf(BadRequestException);
|
||||
});
|
||||
|
||||
it.each([
|
||||
'https://example.com/path',
|
||||
'13800138000',
|
||||
'+86 138-0013-8000',
|
||||
'0755-12345678',
|
||||
'(010) 12345678-123',
|
||||
])('accepts a drainage URL or phone number without a separate name: %s', async (url) => {
|
||||
await expect(validate(ClientDrainageInfoDto, { url })).resolves.toEqual(expect.objectContaining({ url }));
|
||||
});
|
||||
|
||||
it('rejects arbitrary drainage text that is neither a URL nor a phone number', async () => {
|
||||
await expect(validate(ClientDrainageInfoDto, { url: '品牌官网' })).rejects.toBeInstanceOf(BadRequestException);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -101,8 +101,14 @@ export class ClientSmsSignatureUpdateDto extends PartialType(ClientSmsSignatureD
|
||||
}
|
||||
|
||||
export class ClientDrainageInfoDto {
|
||||
@IsString() @MinLength(1) @MaxLength(200) siteName!: string;
|
||||
@IsUrl({ require_tld: false }) @MaxLength(2048) url!: string;
|
||||
@IsOptional() @IsString() @MaxLength(200) siteName?: string;
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(2048)
|
||||
@Matches(/^(?:https?:\/\/\S+|(?:\+?86[\s-]?)?1(?:[\s-]?\d){10}|(?:\+?86[\s-]?)?(?:\(?0\d{2,3}\)?[\s-]?)?\d{7,8}(?:[\s-]?(?:转|ext\.?)?[\s-]?\d{1,6})?)$/i, {
|
||||
message: '引流信息必须是 http/https URL、手机号码或固定电话号码',
|
||||
})
|
||||
url!: string;
|
||||
@IsOptional() @IsString() @MaxLength(1000) remark?: string;
|
||||
@IsOptional() @IsObject() @IsBoundedJsonObject({ maxKeys: 200, maxDepth: 4 }) reportValues?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user