Skip to content

Commit

Permalink
Fix TypeIDGeneratorLive::typeid impl (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii authored Aug 29, 2023
1 parent d4e2678 commit de923dd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zio-uuid/src/main/scala/zio/uuid/TypeIDGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ object TypeIDGenerator {

final class TypeIDGeneratorLive(uuidGenerator: UUIDGenerator) extends TypeIDGenerator {
override def typeid(prefix: String): IO[IllegalArgumentException, TypeID] =
validatePrefix(prefix) match {
case ZValidation.Success(_, _) => uuidGenerator.uuidV7.map(TypeID(prefix, _))
case ZValidation.Failure(_, errors) => ZIO.fail(new IllegalArgumentException(errors.debug.render(Renderer.Scala)))
ZIO.suspendSucceed {
validatePrefix(prefix) match {
case ZValidation.Success(_, _) => uuidGenerator.uuidV7.map(TypeID(prefix, _))
case ZValidation.Failure(_, errors) => ZIO.fail(new IllegalArgumentException(errors.debug.render(Renderer.Scala)))
}
}
}

0 comments on commit de923dd

Please sign in to comment.