refactor: api validators (boolean and date) (#7709)
* refactor: api validators (boolean and date) * chore: open api * revert: time bucket change
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { AudioCodec, CQMode, ToneMapping, TranscodeHWAccel, TranscodePolicy, VideoCodec } from '@app/infra/entities';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsBoolean, IsEnum, IsInt, IsString, Max, Min } from 'class-validator';
|
||||
import { IsEnum, IsInt, IsString, Max, Min } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigFFmpegDto {
|
||||
@IsInt()
|
||||
@@ -68,14 +69,14 @@ export class SystemConfigFFmpegDto {
|
||||
@ApiProperty({ type: 'integer' })
|
||||
npl!: number;
|
||||
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
temporalAQ!: boolean;
|
||||
|
||||
@IsEnum(CQMode)
|
||||
@ApiProperty({ enumName: 'CQMode', enum: CQMode })
|
||||
cqMode!: CQMode;
|
||||
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
twoPass!: boolean;
|
||||
|
||||
@IsString()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { validateCronExpression } from '@app/domain';
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsNotEmpty,
|
||||
IsObject,
|
||||
IsString,
|
||||
@@ -11,6 +9,7 @@ import {
|
||||
ValidatorConstraint,
|
||||
ValidatorConstraintInterface,
|
||||
} from 'class-validator';
|
||||
import { ValidateBoolean, validateCronExpression } from '../../domain.util';
|
||||
|
||||
const isEnabled = (config: SystemConfigLibraryScanDto) => config.enabled;
|
||||
|
||||
@@ -22,7 +21,7 @@ class CronValidator implements ValidatorConstraintInterface {
|
||||
}
|
||||
|
||||
export class SystemConfigLibraryScanDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
|
||||
@ValidateIf(isEnabled)
|
||||
@@ -33,7 +32,7 @@ export class SystemConfigLibraryScanDto {
|
||||
}
|
||||
|
||||
export class SystemConfigLibraryWatchDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { LogLevel } from '@app/infra/entities';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsEnum } from 'class-validator';
|
||||
import { IsEnum } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigLoggingDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
|
||||
@ApiProperty({ enum: LogLevel, enumName: 'LogLevel' })
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { CLIPConfig, RecognitionConfig } from '@app/domain';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsBoolean, IsObject, IsUrl, ValidateIf, ValidateNested } from 'class-validator';
|
||||
import { IsObject, IsUrl, ValidateIf, ValidateNested } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
import { CLIPConfig, RecognitionConfig } from '../../smart-info/dto/model-config.dto';
|
||||
|
||||
export class SystemConfigMachineLearningDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
|
||||
@IsUrl({ require_tld: false, allow_underscores: true })
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { IsBoolean, IsString } from 'class-validator';
|
||||
import { IsString } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigMapDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
|
||||
@IsString()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigNewVersionCheckDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { IsBoolean, IsNotEmpty, IsNumber, IsString, IsUrl, Min, ValidateIf } from 'class-validator';
|
||||
import { IsNotEmpty, IsNumber, IsString, IsUrl, Min, ValidateIf } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
const isEnabled = (config: SystemConfigOAuthDto) => config.enabled;
|
||||
const isOverrideEnabled = (config: SystemConfigOAuthDto) => config.mobileOverrideEnabled;
|
||||
|
||||
export class SystemConfigOAuthDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
autoLaunch!: boolean;
|
||||
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
autoRegister!: boolean;
|
||||
|
||||
@IsString()
|
||||
@@ -27,7 +28,7 @@ export class SystemConfigOAuthDto {
|
||||
@Min(0)
|
||||
defaultStorageQuota!: number;
|
||||
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
|
||||
@ValidateIf(isEnabled)
|
||||
@@ -35,7 +36,7 @@ export class SystemConfigOAuthDto {
|
||||
@IsString()
|
||||
issuerUrl!: string;
|
||||
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
mobileOverrideEnabled!: boolean;
|
||||
|
||||
@ValidateIf(isOverrideEnabled)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigPasswordLoginDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigReverseGeocodingDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { IsBoolean, IsNotEmpty, IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigStorageTemplateDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
@IsBoolean()
|
||||
|
||||
@ValidateBoolean()
|
||||
hashVerificationEnabled!: boolean;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
template!: string;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsBoolean, IsInt, Min } from 'class-validator';
|
||||
import { IsInt, Min } from 'class-validator';
|
||||
import { ValidateBoolean } from '../../domain.util';
|
||||
|
||||
export class SystemConfigTrashDto {
|
||||
@IsBoolean()
|
||||
@ValidateBoolean()
|
||||
enabled!: boolean;
|
||||
|
||||
@IsInt()
|
||||
|
||||
Reference in New Issue
Block a user