Skip to content
GitHub

Pipe

function in meocord/decorator Since 4.1.0

Pipe(): (
  target: new (...args: any[]) => PipeInterface,
  propertyKey?: string | symbol,
) => void

Marks a class as a pipe, which turns one input value into what the handler works with.

Use it on a class that implements PipeInterface, then apply the class with UsePipe or @Validate(schema, { pipes }). To reject input by its shape, a schema with Validate says why more precisely; a pipe throws to stop the call.

Where it runs

  • Pipes — where @UsePipe or @Validate's pipes applies it, after validation

Returns

Returns a property decorator.

(
  target: new (...args: any[]) => PipeInterface,
  propertyKey?: string | symbol,
) => void

Examples

TypeScript
@Pipe()
export class LowercasePipe implements PipeInterface<string, string> {
  transform(value: string): string {
    return value.toLowerCase()
  }
}