feat: Admin shipping options routes to Typescript (#891)
This commit is contained in:
committed by
GitHub
parent
487356a96f
commit
6579c13111
14
packages/medusa/src/utils/validators/is-boolean.ts
Normal file
14
packages/medusa/src/utils/validators/is-boolean.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
// Util function defining the transformation of booleans when part of req.query
|
||||
// e.g. /admin/shipping-options?is_return=false -> false
|
||||
//
|
||||
// We've previously been using @Type(() => Boolean), but this will always return true for strings.
|
||||
// See https://github.com/typestack/class-transformer/issues/676
|
||||
// and https://github.com/typestack/class-transformer/issues/306
|
||||
//
|
||||
// The solution here is stolen from: https://github.com/typestack/class-transformer/issues/676#issuecomment-822699830
|
||||
export const optionalBooleanMapper = new Map([
|
||||
["undefined", undefined],
|
||||
["null", null],
|
||||
["true", true],
|
||||
["false", false],
|
||||
])
|
||||
Reference in New Issue
Block a user