Pipe
function in meocord/decorator Since 4.1.0
Pipe(): (
target: new (...args: any[]) => PipeInterface,
propertyKey?: string | symbol,
) => voidMarks 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
@UsePipeor@Validate'spipesapplies it, after validation
Returns
Returns a property decorator.
(
target: new (...args: any[]) => PipeInterface,
propertyKey?: string | symbol,
) => voidExamples
@Pipe()
export class LowercasePipe implements PipeInterface<string, string> {
transform(value: string): string {
return value.toLowerCase()
}
}