UNPKG

@nestjs/common

Version:

Nest - modern, fast, powerful node.js web framework (@common)

23 lines (22 loc) 862 B
import { isFunction } from './shared.utils.js'; const isPipeLike = (value) => isFunction(value?.transform) || (isFunction(value) && value.prototype && isFunction(value.prototype.transform)); /** * Determines whether a parameter-decorator argument is a * `ParameterDecoratorOptions` object rather than a pipe (instance or class). * * Kept in one place so every decorator (`@Query`, `@Body`, `@Param`, * `@RawBody`, `@Payload`, `@MessageBody`, custom decorators, ...) classifies * arguments identically: a pipe instance that happens to expose a `schema` or * `pipes` property must never be mistaken for an options object. * * @internal */ export function isParameterDecoratorOptions(value) { return (!!value && typeof value === 'object' && !isPipeLike(value) && ('schema' in value || 'pipes' in value)); }