-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding currency support (#680)
* initial version * initial test modifications * fixing tests * adding more tests and revising docs * fixing formatting * updating readme * Revert "updating readme" This reverts commit 77832e2. * fixing tests * fixing json codec test again * removing json currency tests * staging * removing zone offset * fixing null locale * adding ci * Revert "adding ci" This reverts commit 197010c. * removing comparison in currency standard type * adding platform specific tests * Revert "removing comparison in currency standard type" This reverts commit de36381. * fixing formatting and error handling * fixing linting * fixing currency tests * adding docs * fixing bug in patch law and adding tests * revising doc generator and adding test types * updating readme * fixing default currency value * revising docs * finalizing after self-review * fixing broken default currency test
- Loading branch information
Showing
36 changed files
with
561 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
id: standard-type-reference | ||
title: "Standard Type Reference" | ||
--- | ||
# Standard Type Reference | ||
|
||
ZIO Schema provides a number of built-in primitive types, that we can use to represent our data. These can be seen in the following table: | ||
|
||
|Standard Type|JVM Support|ScalaJS Support|Scala Native Support| | ||
|--------------|:--------------:|:--------------:|:--------------:| | ||
|`Boolean`|✅|✅|✅| | ||
|`Byte`|✅|✅|✅| | ||
|`Char`|✅|✅|✅| | ||
|`Chunk[Byte]`|✅|✅|✅| | ||
|`Double`|✅|✅|✅| | ||
|`Float`|✅|✅|✅| | ||
|`Int`|✅|✅|✅| | ||
|`Long`|✅|✅|✅| | ||
|`Short`|✅|✅|✅| | ||
|`String`|✅|✅|✅| | ||
|`Unit`|✅|✅|✅| | ||
|`java.math.BigDecimal`|✅|✅|✅| | ||
|`java.math.BigInteger`|✅|✅|✅| | ||
|`java.time.DayOfWeek`|✅|✅|✅| | ||
|`java.time.Duration`|✅|✅|✅| | ||
|`java.time.Instant`|✅|✅|✅| | ||
|`java.time.LocalDate`|✅|✅|✅| | ||
|`java.time.LocalDateTime`|✅|✅|✅| | ||
|`java.time.LocalTime`|✅|✅|✅| | ||
|`java.time.Month`|✅|✅|✅| | ||
|`java.time.MonthDay`|✅|✅|✅| | ||
|`java.time.OffsetDateTime`|✅|✅|✅| | ||
|`java.time.OffsetTime`|✅|✅|✅| | ||
|`java.time.Period`|✅|✅|✅| | ||
|`java.time.Year`|✅|✅|✅| | ||
|`java.time.YearMonth`|✅|✅|✅| | ||
|`java.time.ZoneId`|✅|✅|✅| | ||
|`java.time.ZoneOffset`|✅|✅|✅| | ||
|`java.time.ZonedDateTime`|✅|✅|✅| | ||
|`java.util.Currency`|✅|❌|❌| | ||
|`java.util.UUID`|✅|❌|✅| |
19 changes: 19 additions & 0 deletions
19
tests/js/src/test/scala-2/zio/schema/PlatformSpecificGen.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package zio.schema | ||
|
||
import zio.schema.SchemaGen.SchemaTest | ||
import zio.schema.StandardTypeGen.StandardTypeAndGen | ||
import zio.test.Gen | ||
|
||
object PlatformSpecificGen { | ||
|
||
val platformSpecificStandardTypes: Gen[Any, StandardType[_]] = Gen.fromIterable( | ||
List.empty | ||
) | ||
|
||
def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[_]): StandardTypeAndGen[_] = | ||
standardTypeGen match { | ||
case _ => StandardType.UnitType -> Gen.unit: StandardTypeAndGen[_] | ||
} | ||
|
||
val platformSpecificSchemasAndGens: List[SchemaTest[_]] = List.empty | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/jvm/src/test/scala-2/zio/schema/PlatformSpecificGen.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package zio.schema | ||
|
||
import zio.schema.SchemaGen.SchemaTest | ||
import zio.schema.StandardTypeGen.StandardTypeAndGen | ||
import zio.test.Gen | ||
|
||
object PlatformSpecificGen { | ||
|
||
val platformSpecificStandardTypes: Gen[Any, StandardType[_]] = Gen.fromIterable( | ||
List( | ||
StandardType.CurrencyType | ||
) | ||
) | ||
|
||
def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[_]): StandardTypeAndGen[_] = | ||
standardTypeGen match { | ||
case typ: StandardType.CurrencyType.type => typ -> Gen.currency | ||
case _ => StandardType.UnitType -> Gen.unit: StandardTypeAndGen[_] | ||
} | ||
|
||
val platformSpecificSchemasAndGens: List[SchemaTest[_]] = List( | ||
SchemaTest("Currency", StandardType.CurrencyType, Gen.currency) | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/native/src/test/scala-2/zio/schema/PlatformSpecificGen.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package zio.schema | ||
|
||
import zio.schema.SchemaGen.SchemaTest | ||
import zio.schema.StandardTypeGen.StandardTypeAndGen | ||
import zio.test.Gen | ||
|
||
object PlatformSpecificGen { | ||
|
||
val platformSpecificStandardTypes: Gen[Any, StandardType[_]] = Gen.fromIterable( | ||
List.empty | ||
) | ||
|
||
def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[_]): StandardTypeAndGen[_] = | ||
standardTypeGen match { | ||
case _ => StandardType.UnitType -> Gen.unit: StandardTypeAndGen[_] | ||
} | ||
|
||
val platformSpecificSchemasAndGens: List[SchemaTest[_]] = List.empty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.