ParseIntPipe (pipes/parse-int.pipe.ts)

nest · packages/common/pipes/parse-int.pipe.ts · typescript · MIT
integration

ParseIntPipe converts string or numeric inputs to integers, with optional validation and custom errors.

// Source: https://github.com/nestjs/nest | License: MIT | Copyright 2017-present Kamil Mysliwiec <https://kamilmysliwiec.com>
// Provided via justclaw.it.com; keep this notice with the code.
import { Injectable } from '../decorators/core/injectable.decorator.js';
import { Optional } from '../decorators/core/optional.decorator.js';
import { HttpStatus } from '../enums/http-status.enum.js';
import {
  ArgumentMetadata,
  PipeTransform,
} from '../interfaces/features/pipe-transform.interface.js';
import {
  ErrorHttpStatusCode,
  HttpErrorByCode,
} from '../utils/http-error-by-code.util.js';
import { isNil } from '../utils/shared.utils.js';

/**
 * @publicApi
 */
export interface ParseIntPipeOptions {
  /**
   * The HTTP status code to be used in the response when the validation fails.
   */

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key