class-validator#isNumber TypeScript Examples

The following examples show how to use class-validator#isNumber. 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: classes.ts    From epicgames-freegames-node with MIT License 6 votes vote down vote up
/**
   * Number of hours to wait for a response for a notification.
   * The notification wait is blocking, so while other accounts will still continue, the process won't exit until all captcha requests are solved.
   * If the timeout is reached, the process will exit, and the URL in the notification will be inaccessible.
   * @example 168
   * @default 24
   * @env NOTIFICATION_TIMEOUT_HOURS
   */
  @IsOptional()
  @IsNumber()
  @Min(0)
  notificationTimeoutHours = process.env.NOTIFICATION_TIMEOUT_HOURS
    ? parseInt(process.env.NOTIFICATION_TIMEOUT_HOURS, 10)
    : 24;
Example #2
Source File: pagination-args.dto.ts    From ironfish-api with Mozilla Public License 2.0 6 votes vote down vote up
@ApiPropertyOptional({
    description: 'A limit on the number of objects to return between 1 and 100',
  })
  @Max(100)
  @Min(1)
  @IsNumber()
  @IsOptional()
  @Type(() => Number)
  readonly limit?: number;
Example #3
Source File: update-review.dto.ts    From edu-server with MIT License 6 votes vote down vote up
/**
   * The number of stars given in the review
   * @example 5
   */
  @IsNotEmpty()
  @IsNumber()
  @Max(5)
  @Min(0)
  stars: number;
Example #4
Source File: pagination-params.dto.ts    From nestjs-starter-rest-api with MIT License 6 votes vote down vote up
@ApiPropertyOptional({
    description: 'Optional, defaults to 100',
    type: Number,
  })
  @IsNumber()
  @IsOptional()
  @Min(0)
  @Transform(({ value }) => parseInt(value, 10), { toClassOnly: true })
  limit = 100;
Example #5
Source File: create-review.dto.ts    From edu-server with MIT License 6 votes vote down vote up
/**
   * The number of stars given in the review
   * @example 5
   */
  @IsNotEmpty()
  @IsNumber()
  @Max(5)
  @Min(0)
  stars: number;
Example #6
Source File: pagination-params.dto.ts    From nestjs-starter-rest-api with MIT License 6 votes vote down vote up
@ApiPropertyOptional({
    description: 'Optional, defaults to 0',
    type: Number,
  })
  @IsNumber()
  @IsOptional()
  @Min(0)
  @Transform(({ value }) => parseInt(value, 10), { toClassOnly: true })
  offset = 0;
Example #7
Source File: pagination-args.dto.ts    From ironfish-api with Mozilla Public License 2.0 6 votes vote down vote up
@ApiPropertyOptional({
    description:
      'An object identifier to use as a cursor pagination to fetch records before',
  })
  @Max(Number.MAX_SAFE_INTEGER)
  @ApiPropertyOptional()
  @IsNumber()
  @IsOptional()
  @Type(() => Number)
  readonly before?: number;
Example #8
Source File: import.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
@IsOptional()
    @IsNumber()
    records_inserted?: number;
Example #9
Source File: createSubmission.dto.ts    From coronatest with GNU Affero General Public License v3.0 5 votes vote down vote up
@IsNumber()
    @Min(0)
    @Max(200)
    age: number;
Example #10
Source File: field.dto.ts    From ironfish-api with Mozilla Public License 2.0 5 votes vote down vote up
@IsNumber()
  @Max(Number.MAX_SAFE_INTEGER)
  @Min(0)
  @Type(() => Number)
  readonly value!: number;
Example #11
Source File: weather-city.dto.ts    From life-helper-backend with MIT License 5 votes vote down vote up
/** 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */
  @IsNumber()
  @Min(-180)
  @Max(180)
  longitude: number
Example #12
Source File: createSubmission.dto.ts    From coronatest with GNU Affero General Public License v3.0 5 votes vote down vote up
@Min(36)
    @Max(50)
    @IsNumber()
    @IsOptional()
    fever_temperature: number;
Example #13
Source File: import.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
// composite properties pulled in by JOIN statements when the db fetches this record
    @IsOptional()
    @IsNumber()
    total_records?: number;
Example #14
Source File: update-account-settings.dto.ts    From etherspot-sdk with MIT License 5 votes vote down vote up
@IsOptional()
  @IsNumber()
  delayTransactions?: number;
Example #15
Source File: createRecord.ts    From ts-di-starter with MIT License 5 votes vote down vote up
@IsNumber()
  value: number;
Example #16
Source File: ClassValidator.spec.ts    From typescript-clean-architecture with MIT License 5 votes vote down vote up
@IsNumber()
  public numberProperty: number;
Example #17
Source File: ParametersValidator.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
static validatePrimitive(schema: string, value: any) {
    let message: string
    let isValid: boolean = true

    switch (schema) {
      case did:
        isValid = matches(value, DID)
        message = `Parameter "${value}" is not a valid. Valid format: (${DID}).`
        break

      case didMethod:
        isValid = matches(value, DID_METHOD)
        message = `Parameter "${value}" is not a valid. Valid format: (${DID_METHOD}).`
        break

      case jwt:
        isValid = matches(value, JWT)
        message = `Parameter "${value}" is not a valid JWT. Valid format: (${JWT}).`
        break

      case array:
        isValid = isArray(value)
        message = `Parameter "${value}" should be an array.`
        break

      case number:
        isValid = isNumber(value)
        message = `Parameter "${value}" should be a number.`
        break

      case object:
        isValid = isObject(value)
        message = `Parameter "${value}" should be an object.`
        break

      case string:
        isValid = isString(value)
        message = `Parameter "${value}" should be a string.`
        break

      case boolean:
        isValid = isBoolean(value)
        message = `Parameter "${value}" should be a boolean.`
        break

      case isoString:
        isValid = isISO8601(value)
        message = `Parameter "${value}" is not a valid ISO 8601 date string.`
        break

      case confirmationCode:
        isValid = matches(value, COGNITO_CONFIRMATION_CODE)
        message = `Parameter "${value}" is not a valid confirmation code. Valid format: (${COGNITO_CONFIRMATION_CODE}).`
        break

      case password:
        isValid = matches(value, PASSWORD)
        message = `Parameter "${value}" is not a password. Valid format: (${PASSWORD}).`
        break
    }

    return { isValid, message }
  }
Example #18
Source File: Pagination.ts    From tatum-blockchain-connector with MIT License 5 votes vote down vote up
@IsNumber()
    @IsOptional()
    public offset?: number;
Example #19
Source File: class-validator.ts    From pebula-node with MIT License 5 votes vote down vote up
@IsNumber()
  maxNumber!: number;
Example #20
Source File: index.ts    From office-hours with GNU General Public License v3.0 5 votes vote down vote up
@IsNumber()
  courseId!: number;
Example #21
Source File: createSubmission.dto.ts    From coronatest with GNU Affero General Public License v3.0 5 votes vote down vote up
@IsNumber()
    @Min(1)
    @Max(200)
    @IsOptional()
    symptoms_duration: number;
Example #22
Source File: FileMetadata.ts    From typescript-clean-architecture with MIT License 5 votes vote down vote up
@IsOptional()
  @IsNumber()
  public readonly size: Nullable<number>;
Example #23
Source File: create-transaction.dto.ts    From bank-server with MIT License 5 votes vote down vote up
@IsNumber()
  @IsNotEmpty()
  @ApiProperty()
  readonly amountMoney: number;
Example #24
Source File: pagination-params.class.ts    From mamori-i-japan-api with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@ApiPropertyOptional({
    description: 'Optional, defaults to 0',
    type: Number,
  })
  @IsNumber()
  @IsOptional()
  @Transform((value) => parseInt(value, 10), { toClassOnly: true })
  offset = 0
Example #25
Source File: config.ts    From ts-di-starter with MIT License 5 votes vote down vote up
@IsNumber()
  port: number;
Example #26
Source File: filter-collection.dto.ts    From aqualink-app with MIT License 5 votes vote down vote up
@ApiProperty({ example: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  @Validate(EntityExists, [Site])
  siteId?: number;
Example #27
Source File: shared.dto.ts    From affinidi-core-sdk with Apache License 2.0 5 votes vote down vote up
@IsOptional()
  @IsNumber()
  expiresIn?: number
Example #28
Source File: hero-damaged-enemy.dto.ts    From nestjs-geteventstore with MIT License 5 votes vote down vote up
@IsNumber()
  hitPoint: number;
Example #29
Source File: posts.entity.ts    From NestJs-youtube with MIT License 5 votes vote down vote up
@Column({ default: 0, type: 'int' })
  @IsEmpty({ always: true, message: 'hey...' })
  @IsNumber({ allowNaN: false, allowInfinity: false })
  // tslint:disable-next-line: variable-name
  comments_num: number;