class-validator#ValidateIf TypeScript Examples

The following examples show how to use class-validator#ValidateIf. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: block-query.dto.ts    From ironfish-api with Mozilla Public License 2.0 6 votes vote down vote up
@ApiPropertyOptional({
    description:
      'Block sequence. Will only return blocks on the main chain if provided',
  })
  @ValidateIf((o: BlockQueryDto) => o.hash === undefined)
  @IsDefined({
    message: '"hash" or "sequence" required to query for single block',
  })
  @Max(Number.MAX_SAFE_INTEGER)
  @Min(1)
  @IsInt()
  @Type(() => Number)
  readonly sequence?: number;
Example #2
Source File: type_transformation.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
@ValidateIf((o) => o.metatype_relationship_pair_id === null && typeof o.metatype_relationship_pair_id === 'undefined')
    @IsString()
    destination_id_key?: string;
Example #3
Source File: block-query.dto.ts    From ironfish-api with Mozilla Public License 2.0 5 votes vote down vote up
@ApiPropertyOptional({ description: 'Block hash' })
  @ValidateIf((o: BlockQueryDto) => o.sequence === undefined)
  @IsDefined({
    message: '"hash" or "sequence" required to query for single block',
  })
  @IsString()
  readonly hash?: string;
Example #4
Source File: type_transformation.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
@ValidateIf((o) => o.metatype_relationship_pair_id === null && typeof o.metatype_relationship_pair_id === 'undefined')
    @IsString()
    origin_data_source_id?: string;
Example #5
Source File: user-metrics-query.dto.ts    From ironfish-api with Mozilla Public License 2.0 5 votes vote down vote up
@ApiPropertyOptional({
    description: `ISO 8601 start date for user metrics request. Required for ${MetricsGranularity.TOTAL} requests`,
  })
  @ValidateIf((o: UserMetricsQueryDto) => Boolean(o.end))
  @IsDate()
  @Type(() => Date)
  readonly start?: Date;
Example #6
Source File: order.entity.ts    From rest-api.ts with MIT License 5 votes vote down vote up
@IsPositive()
  @ValidateIf(total => total >= 0)
  @Column({type: 'integer', default: 0, unsigned: true})
  total: number;
Example #7
Source File: create-admin.dto.ts    From mamori-i-japan-api with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@ApiPropertyOptional({
    description: 'Optional, needed when admin role is PREFECTURE_ADMIN_ROLE',
  })
  @ValidateIf((o) => o.adminRole === AdminRole.prefectureAdminRole)
  @IsInt()
  @Min(0)
  @Max(47)
  prefectureId: number
Example #8
Source File: index.ts    From office-hours with GNU General Public License v3.0 5 votes vote down vote up
@ValidateIf((o) => o.phoneNotifsEnabled)
  @IsString()
  @IsNotEmpty()
  phoneNumber?: string;
Example #9
Source File: Pagination.ts    From tatum-blockchain-connector with MIT License 5 votes vote down vote up
@IsNumberString()
  @Matches(/[0-9]+/)
  @IsNotEmpty()
  @ValidateIf(o => o.count !== 'true')
  @IsInRange(1, 50)
  public pageSize: string;
Example #10
Source File: account.entities.ts    From tradingview-alerts-processor with MIT License 5 votes vote down vote up
@IsString()
  @ValidateIf((account: Account) => account.exchange === ExchangeId.KuCoin)
  passphrase?: string;
Example #11
Source File: edge.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
@ValidateIf((o) => o.origin_original_id === null && typeof o.origin_original_id === 'undefined')
    @IsString()
    origin_id?: string;
Example #12
Source File: EntityPageCreateInput.ts    From amplication with Apache License 2.0 5 votes vote down vote up
@ValidateIf(o => o.pageType === EnumEntityPageType.SingleRecord)
  @IsNotEmpty()
  @Field(() => EntityPageSingleRecordSettings, {
    nullable: true
  })
  singleRecordSettings?: EntityPageSingleRecordSettings & JsonValue;
Example #13
Source File: role.validator.ts    From ddd-cqrs-es-aws-sam with MIT License 5 votes vote down vote up
@ValidateIf(o => o.disabled !== undefined)
  @Equals(false)
  disabled!: boolean;
Example #14
Source File: user.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
@ValidateIf((o) => o.identity_provider !== 'username_password' && o.type === 'user')
    @IsString()
    identity_provider_id?: string;
Example #15
Source File: EntityPage.ts    From amplication with Apache License 2.0 5 votes vote down vote up
@ValidateIf(o => !o.showAllFields)
  @IsNotEmpty()
  @Field(() => [String], {
    nullable: true,
    description: undefined
  })
  showFieldList?: string[];
Example #16
Source File: edge.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
@ValidateIf((o) => o.destination_original_id === null && typeof o.destination_original_id === 'undefined')
    @IsString()
    destination_id?: string;