Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a customized localized formatters for DocumentData Duration, Instant, Money types #47

Open
adrw opened this issue Apr 11, 2020 · 1 comment

Comments

@adrw
Copy link
Collaborator

adrw commented Apr 11, 2020

For example, a DocumentData with a paramter of type Money could include a lambda on how to format that anytime it is rendered removing the need for every DocumentData constructor to format before construction.

data class RecipientReceipt(
  val sender: String,
  @BarberField(fomat = { amount ->
    Money.of(amount).asCasual()
  })
  val amount: Money,
  val cancelUrl: String,
  @BarberField(format = { dateTime -> Instant.of(dateTime).format("YYYY-MM-DD") })
  val deposit_expected_at: Instant
) : DocumentData
@adrw
Copy link
Collaborator Author

adrw commented Oct 5, 2020

Instead of this, we can make DocumentData a proto and accept Duration, Instant, and Amount/Money as non-string types, then add configurable formatters as configuration methods to the Barbershop

#51

@adrw adrw changed the title Add a format paramter to @BarberField to accept a lambda for formatting complex DocumentData values Add a customized localized formatters for DocumentData Duration, Instant, Money types Oct 5, 2020
@adrw adrw mentioned this issue Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant