peek-travel / swift-currency

Interact with and calculate values of currencies in a type-safe way.
MIT License
108 stars 5 forks source link

[RFC] Add PropertyWrapper for Primitives #2

Open Mordil opened 4 years ago

Mordil commented 4 years ago

Desired Functionality

Rather than working with the protocol Money, or any of the concrete implementations directly, I would like the ability to progressively work with the Currency module by wrapping properties in my projects with a new PropertyWrapper that would handle all of the minorUnits and type constraints for me.

Proposed Naming

CurrencyValue

struct Foo {
    @CurrencyValue(USD.self) var price: Decimal
}

Format subtype

struct Foo {
    @USD.Format var price: Decimal
}
Mordil commented 4 years ago

This was suggested from the Vapor Discord.