Skip to content

Commit f2dcbbb

Browse files
committed
Add QueryBindable conformance to Decimal
1 parent 6b3f436 commit f2dcbbb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/StructuredQueriesCore/QueryBindable+Foundation.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,20 @@ extension URL: QueryBindable {
2323
}
2424
}
2525

26+
extension Decimal: QueryBindable {
27+
public var queryBinding: QueryBinding {
28+
.text(description)
29+
}
30+
31+
public init(decoder: inout some QueryDecoder) throws {
32+
let string = try String(decoder: &decoder)
33+
guard let decimal = Decimal(string: string) else {
34+
throw InvalidDecimal()
35+
}
36+
self = decimal
37+
}
38+
}
39+
2640
private struct InvalidURL: Error {}
41+
42+
private struct InvalidDecimal: Error {}

0 commit comments

Comments
 (0)