Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit d8642e0

Browse files
committed
Validate bool query params as enum, not presence
Addresses the following review comments: - #162 (comment) - #162 (comment) - #162 (comment)
1 parent 11cb5a8 commit d8642e0

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/handlers/swap_handlers.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,10 @@ const parseGetSwapQuoteRequestParams = (req: express.Request): GetSwapQuoteReque
180180
const rfqt =
181181
req.query.intentOnFilling === undefined
182182
? undefined
183-
: {
184-
intentOnFilling: ['true', ''].includes(req.query.intentOnFilling) ? true : false,
185-
};
183+
: { intentOnFilling: req.query.intentOnFilling === 'true' ? true : false };
186184
// tslint:disable-next-line:boolean-naming
187185
const skipValidation =
188-
req.query.skipValidation === undefined ? false : ['true', ''].includes(req.query.skipValidation) ? true : false;
186+
req.query.skipValidation === undefined ? false : req.query.skipValidation === 'true' ? true : false;
189187
return {
190188
takerAddress,
191189
sellToken,

src/schemas/swap_quote_request_schema.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
},
2828
"intentOnFilling": {
2929
"type": "string",
30-
"allowEmptyValue": true
30+
"enum": ["true", "false"]
3131
},
3232
"skipValidation": {
3333
"type": "string",
34-
"allowEmptyValue": true
34+
"enum": ["true", "false"]
3535
}
3636
},
3737
"required": ["sellToken", "buyToken"],

0 commit comments

Comments
 (0)