Skip to content

Commit fb18b54

Browse files
committed
Add @params decorator options
1 parent 316d62d commit fb18b54

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/decorator/Params.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1+
import {ParamOptions} from "../decorator-options/ParamOptions";
12
import {getMetadataArgsStorage} from "../index";
23

34
/**
45
* Injects all request's route parameters to the controller action parameter.
56
* Must be applied on a controller action parameter.
67
*/
7-
export function Params(): Function {
8+
export function Params(options?: ParamOptions): Function {
89
return function (object: Object, methodName: string, index: number) {
910
getMetadataArgsStorage().params.push({
1011
type: "params",
1112
object: object,
1213
method: methodName,
1314
index: index,
14-
parse: false, // it does not make sense for Param to be parsed
15-
required: false,
16-
classTransform: undefined
15+
parse: options ? options.parse : false,
16+
required: options ? options.required : undefined,
17+
classTransform: options ? options.transform : undefined,
18+
explicitType: options ? options.type : undefined,
19+
validate: options ? options.validate : undefined,
1720
});
1821
};
19-
}
22+
}

0 commit comments

Comments
 (0)