Skip to content

Commit

Permalink
removing redundant class validators IsDefined and IsString (#2053)
Browse files Browse the repository at this point in the history
Co-authored-by: Zack Lee <[email protected]>
Co-authored-by: danoswaltCL <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent 73b7150 commit 4e99647
Show file tree
Hide file tree
Showing 25 changed files with 27 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class AssignmentStateUpdateValidator {

@IsNotEmpty()
@IsUUID()
@IsDefined()
public experimentId: string;

@IsDefined()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import { IsNotEmpty, IsDefined, IsString, IsJSON, IsObject } from 'class-validator';
import { Attempt, CaliperActor, ScoreObject, SUPPORTED_CALIPER_EVENTS, SUPPORTED_CALIPER_PROFILES } from 'upgrade_types';
import { IsNotEmpty, IsString, IsJSON, IsObject } from 'class-validator';
import {
Attempt,
CaliperActor,
ScoreObject,
SUPPORTED_CALIPER_EVENTS,
SUPPORTED_CALIPER_PROFILES,
} from 'upgrade_types';

export class CaliperLogData {

@IsDefined()
@IsNotEmpty()
@IsString()
public profile: SUPPORTED_CALIPER_PROFILES;

@IsDefined()
@IsNotEmpty()
@IsString()
public type: SUPPORTED_CALIPER_EVENTS;

@IsDefined()
@IsNotEmpty()
@IsJSON()
public actor: CaliperActor;

@IsDefined()
@IsNotEmpty()
@IsString()
public action: string;

@IsDefined()
@IsNotEmpty()
@IsString()
public eventTime: string;

@IsDefined()
@IsNotEmpty()
@IsJSON()
public object: Attempt;
Expand All @@ -40,5 +39,4 @@ export class CaliperLogData {
@IsNotEmpty()
@IsJSON()
public generated: ScoreObject;

}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { IsNotEmpty, IsDefined, IsString } from 'class-validator';
import { IsNotEmpty, IsString } from 'class-validator';
import { CaliperLogData } from './CaliperLogData';


export class CaliperLogEnvelope {
@IsDefined()
@IsNotEmpty()
@IsString()
public sensor: string;

@IsDefined()
@IsNotEmpty()
@IsString()
public sendTime: string;

@IsDefined()
@IsNotEmpty()
@IsString()
public dataVersion: string;

public data: CaliperLogData[];
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { IsNotEmpty, IsString, IsDefined } from 'class-validator';
import { IsNotEmpty, IsString } from 'class-validator';

export class DataExportValidator {
@IsString()
@IsNotEmpty()
@IsDefined()
public experimentId: string;

@IsString()
@IsNotEmpty()
@IsDefined()
public email: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { IsNotEmpty, IsString, IsDefined, IsArray } from 'class-validator';
import { IsNotEmpty, IsString, IsArray } from 'class-validator';

export class DataLogAnalysisValidator {
@IsString({each: true})
@IsString({ each: true })
@IsNotEmpty()
@IsDefined()
@IsArray()
public queryIds: string[];
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { IsNotEmpty, IsDefined, IsString } from 'class-validator';
import { IsNotEmpty, IsString } from 'class-validator';

export class ExperimentAssignmentValidatorv6 {
@IsNotEmpty()
@IsDefined()
@IsString()
public context: string;
}

export class ExperimentAssignmentValidator extends ExperimentAssignmentValidatorv6 {
@IsNotEmpty()
@IsDefined()
@IsString()
public userId: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { IsArray, IsNotEmpty, IsString, IsUUID } from 'class-validator';
import { IsArray, IsNotEmpty, IsUUID } from 'class-validator';

export class ExperimentIds {
@IsArray()
@IsNotEmpty()
@IsString({ each: true })
@IsUUID('all', { each: true })
public ids: string[];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsNotEmpty, IsDefined, IsNumber, IsEnum, IsString, ValidateNested, IsOptional } from 'class-validator';
import { IsNotEmpty, IsNumber, IsEnum, IsString, ValidateNested, IsOptional } from 'class-validator';
import { EXPERIMENT_SEARCH_KEY, SORT_AS_DIRECTION, EXPERIMENT_SORT_KEY } from '../../models/Experiment';
import { Type } from 'class-transformer';

Expand All @@ -8,7 +8,6 @@ class ExperimentSearchParam {
public key: EXPERIMENT_SEARCH_KEY;

@IsNotEmpty()
@IsDefined()
@IsString()
public string: string;
}
Expand All @@ -26,12 +25,10 @@ class ExperimentSortParam {
export class ExperimentPaginatedParamsValidator {
@IsNotEmpty()
@IsNumber()
@IsDefined()
public skip: number;

@IsNotEmpty()
@IsNumber()
@IsDefined()
public take: number;

@IsOptional()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsNotEmpty, IsDefined, IsArray, IsString } from 'class-validator';
import { IsNotEmpty, IsArray, IsString } from 'class-validator';

export class ExperimentUserAliasesValidatorv6 {
@IsArray()
Expand All @@ -8,6 +8,5 @@ export class ExperimentUserAliasesValidatorv6 {

export class ExperimentUserAliasesValidator extends ExperimentUserAliasesValidatorv6 {
@IsNotEmpty()
@IsDefined()
public userId: string;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { IsNotEmpty, IsDefined, IsString } from 'class-validator';
import { IsNotEmpty, IsString } from 'class-validator';
export class FailedParamsValidator {
@IsDefined()
@IsNotEmpty()
@IsString()
public experimentPoint: string;

@IsString()
@IsDefined()
@IsNotEmpty()
public reason: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class GroupValidator {
class SegmentValidator {
@IsOptional()
@IsUUID()
@IsString()
public id?: string;

@IsNotEmpty()
Expand All @@ -55,7 +54,6 @@ class SegmentValidator {
class SegmentImportValidator {
@IsOptional()
@IsUUID()
@IsString()
public id?: string;

@IsNotEmpty()
Expand Down Expand Up @@ -96,7 +94,6 @@ class FeatureFlagListImportValidator {
public enabled: boolean;

@IsNotEmpty()
@IsDefined()
public listType: string;

@ValidateNested()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { SegmentInputValidator } from './SegmentInputValidator';
export class FeatureFlagListValidator {
@IsNotEmpty()
@IsUUID()
@IsDefined()
public flagId: string;

@IsDefined()
@IsBoolean()
public enabled: boolean;

@IsNotEmpty()
@IsDefined()
public listType: string;

@ValidateNested()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FEATURE_FLAG_STATUS } from 'upgrade_types';
export class FeatureFlagStatusUpdateValidator {
@IsNotEmpty()
@IsUUID()
@IsDefined()
public flagId: string;

@IsDefined()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export class FeatureFlagCoreValidation {
public id: string;

@IsNotEmpty()
@IsDefined()
@IsString()
public name: string;

Expand All @@ -19,12 +18,10 @@ export class FeatureFlagCoreValidation {
public description: string;

@IsNotEmpty()
@IsDefined()
@IsString()
public key: string;

@IsNotEmpty()
@IsDefined()
@IsEnum(FEATURE_FLAG_STATUS)
public status: FEATURE_FLAG_STATUS;

Expand Down Expand Up @@ -59,19 +56,16 @@ export class FeatureFlagValidation extends FeatureFlagCoreValidation {

export class UserParamsValidator {
@IsNotEmpty()
@IsDefined()
@IsString()
public userId: string;

@IsNotEmpty()
@IsDefined()
@IsString()
public context: string;
}

export class IdValidator {
@IsNotEmpty()
@IsDefined()
@IsUUID()
public id: string;
}
Expand All @@ -86,7 +80,6 @@ export class FeatureFlagImportValidation {
class FeatureFlagFile {
@IsString()
@IsNotEmpty()
@IsDefined()
public fileName: string;

@IsString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Type } from 'class-transformer';
import { IsNotEmpty, IsDefined, IsNumber, IsOptional, ValidateNested, IsEnum, IsString } from 'class-validator';
import { IsNotEmpty, IsNumber, IsOptional, ValidateNested, IsEnum, IsString } from 'class-validator';
import { SORT_AS_DIRECTION } from 'upgrade_types';

// TODO: Move to upgrade types
Expand Down Expand Up @@ -61,12 +61,10 @@ class IFeatureFlagSearchParamsValidator {
export class FeatureFlagPaginatedParamsValidator {
@IsNotEmpty()
@IsNumber()
@IsDefined()
public skip: number;

@IsNotEmpty()
@IsNumber()
@IsDefined()
public take: number;

@IsOptional()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Type } from 'class-transformer';
import {
IsNotEmpty,
IsDefined,
IsString,
ValidateNested,
IsArray,
Expand Down Expand Up @@ -87,7 +86,6 @@ class ILogInputValidator implements ILogInput {
}

export class LogValidatorv6 implements ILogRequestBody {
@IsDefined()
@IsNotEmpty()
@IsArray()
@ValidateNested({ each: true })
Expand All @@ -96,7 +94,6 @@ export class LogValidatorv6 implements ILogRequestBody {
}

export class LogValidator extends LogValidatorv6 implements ILogRequestBody {
@IsDefined()
@IsNotEmpty()
@IsString()
public userId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AssignedCondition {
class Data {
@IsString()
@IsNotEmpty()
@IsDefined()
site: string;

@IsString()
Expand All @@ -33,7 +32,6 @@ class Data {

export class MarkExperimentValidatorv5 {
@IsNotEmpty()
@IsDefined()
public userId: string;

@IsDefined()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AssignedCondition {
class Data {
@IsString()
@IsNotEmpty()
@IsDefined()
site: string;

@IsString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Type } from 'class-transformer';
import { IsNotEmpty, IsDefined, IsNumber, IsString, IsEnum, IsOptional, ValidateNested } from 'class-validator';
import { IsNotEmpty, IsNumber, IsString, IsEnum, IsOptional, ValidateNested } from 'class-validator';
import { SORT_AS_DIRECTION } from 'upgrade_types';
class SortParamsValidator {
@IsNotEmpty()
Expand All @@ -23,12 +23,10 @@ class SearchParamsValidator {
export class PaginatedParamsValidator {
@IsNotEmpty()
@IsNumber()
@IsDefined()
public skip: number;

@IsNotEmpty()
@IsNumber()
@IsDefined()
public take: number;

@IsOptional()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IsNotEmpty, IsDefined } from 'class-validator';
import { IsNotEmpty } from 'class-validator';

export class ScheduledJobsParamsValidator {
@IsNotEmpty()
@IsDefined()
public id: string;
}
Loading

0 comments on commit 4e99647

Please sign in to comment.