Skip to content

Releases: kevin-lee/refined4s

v0.15.0

13 Apr 11:48
Compare
Choose a tag to compare

0.15.0 - 2024-04-13

New Features

  • [refined4s-core] Add NonBlankString which can be neither all whitespace chars nor an empty String (#281)

    NonBlankString("")
    // Invalid value: [""]. It must be not all whitespace non-empty String
    
    NonBlankString(" ")
    // Invalid value: [" "]. It must be not all whitespace non-empty String
    
    NonBlankString("   ")
    // Invalid value: ["   "]. It must be not all whitespace non-empty String
    
    NonBlankString("\n")
    // Invalid value: ["\n"]. It must be not all whitespace non-empty String
    
    NonBlankString("\t")
    // Invalid value: ["\t"]. It must be not all whitespace non-empty String
    
    NonBlankString("\t\n")
    // Invalid value: ["\t\n"]. It must be not all whitespace non-empty String
    
    NonBlankString(" \t \n")
    // Invalid value: [" \t \n"]. It must be not all whitespace non-empty String
  • [refined4s-cats] Add cats support for NonBlankString (#283)

  • [refined4s-circe] Add circe support for NonBlankString (#284)

  • [refined4s-pureconfig] Add pureconfig support for NonBlankString (#285)

  • [refined4s-doobie] Add doobie support for NonBlankString (#286)

  • [refined4s-extras-render] Add extras-render support for NonBlankString (#287)

  • [refined4s-tapir] Add tapir support for NonBlankString (#288)

v0.14.0

05 Apr 10:35
Compare
Choose a tag to compare

0.14.0 - 2024-04-05

New Features

  • Add refined4s-tapir to support tapir (#272)
  • [refined4s-tapir] Add TapirNewtypeSchema and TapirRefinedSchema to support sttp.tapir.Schema for refined4s (#273)
  • [refined4s-tapir] Add Schemas for pre-defined refined types (#276)
  • [refined4s-tapir] Add Schema type-class instances with auto deriving (#278)

v0.13.0

21 Jan 01:09
Compare
Choose a tag to compare

0.13.0 - 2024-01-21

New Features

  • [refined4s-core] Add Url to refined4s.types.network and the type-class instances for Url in the other modules (#246)

  • [refined4s-core] Add Uuid String which can be validated as java.util.UUID and the type-class instances for Uuid in the other modules (#248)

  • [refined4s-core] Add Uri.apply(java.net.URI) (#251)

  • [refined4s-core] Add Url.apply(java.net.URL) (#252)

  • [refined4s-refined-compat-scala2] Add Uri, Url and Uuid (#255)

v0.12.0

20 Jan 06:19
Compare
Choose a tag to compare

0.12.0 - 2024-01-20

New Feature

  • [refined4s-core] Make pre-defined types in types.all importable from each type category (i.e. numeric, strings and network) (#237)

    So it means a type like refined4s.types.numeric.NegInt should be exactly the same as refined4s.types.all.NegInt.


  • Add refined4s-refined-compat modules for compatibility with the refined library in Scala 2 (#241)
    • refined4s-refined-compat-scala2 for compatibility with refined in Scala 2
    • refined4s-refined-compat-scala3 for just using refined4s in Scala 3

  • Add RefinedCompatAllTypes to refined4s-refined-compat-scala2 and refined4s-refined-compat-scala3 (#243)

Internal Change

  • [refined4s-core] Move MinValue and MaxValue from each MinMax to Min and Max (#239)

    e.g.)

    type NegInt = NegInt.Type
    object NegInt extends Numeric[Int], MinMax[Int] {
      override def min: Type = apply(Int.MinValue)
      override def max: Type = apply(-1)
    
      val MinValue: Type = min
      val MaxValue: Type = max
    }

    to

    trait Min[A] {
      self: NewtypeBase[A] =>
      def min: Type
    
      val MinValue: Type = min
    }
    
    trait Max[A] {
      self: NewtypeBase[A] =>
      def max: Type
    
      val MaxValue: Type = max
    }

v0.11.0

04 Jan 02:25
Compare
Choose a tag to compare

0.11.0 - 2024-01-04

New Feature

  • [refined4s-core] Add MinValue and MaxValue to refined basic numeric types (#223)

    • Add Min trait
    • Add Max trait
    • Add MinMax trait

    Add MinMax to the following types to have MinValue and MaxValue

    • NegInt
    • NonNegInt
    • PosInt
    • NonPosInt
    • NegLong
    • NonNegLong
    • PosLong
    • NonPosLong
    • NegShort
    • NonNegShort
    • PosShort
    • NonPosShort
    • NegByte
    • NonNegByte
    • PosByte
    • NonPosByte
    • NegFloat
    • NonNegFloat
    • PosFloat
    • NonPosFloat
    • NegDouble
    • NonNegDouble
    • PosDouble
    • NonPosDouble

Internal Change

  • [refined4s-core] Move Numeric and InlinedNumeric from numeric trait to numeric object (#225)

v0.10.0

02 Jan 07:58
Compare
Choose a tag to compare

0.10.0 - 2024-01-02

New Feature

  • Release refined4s-extras-render module (#220)
  • Add refined4s-extras-render to support Render for refined4s (#215)
    refined4s.modules.extras.derivation.ExtrasRender
    refined4s.modules.extras.derivation.types.all.given
    refined4s.modules.extras.derivation.generic.auto.given
    e.g.)
    import extras.render.Render
    
    import refined4s.types.all.*
    import refined4s.modules.extras.derivation.types.all.given
    
    val name = NonEmptyString("Kevin")
    Render[NonEmptyString].render(name)
    // String = Kevin
    import extras.render.Render
    
    import refined4s.Newtype
    import refined4s.modules.extras.derivation.ExtrasRender
    
    type Name = Name.Type
    object Name extends Newtype[String], ExtrasRender[String]
    
    val name = Name("Kevin")
    Render[Name].render(name)
    // String = Kevin
    import extras.render.Render
    
    import refined4s.Newtype
    
    type Name = Name.Type
    object Name extends Newtype[String]
    
    import refined4s.modules.extras.derivation.generic.auto.given
    
    val name = Name("Kevin")
    Render[Name].render(name)
    // String = Kevin

v0.9.0

02 Jan 06:23
Compare
Choose a tag to compare

0.9.0 - 2024-01-02

NOTE:
refined4s-extras-render was not released by mistake, and it will be released in v0.10.0.

New Feature

  • Add refined4s-extras-render to support Render for refined4s (#215)
    refined4s.modules.extras.derivation.ExtrasRender
    refined4s.modules.extras.derivation.types.all.given
    refined4s.modules.extras.derivation.generic.auto.given
    e.g.)
    import extras.render.Render
    
    import refined4s.types.all.*
    import refined4s.modules.extras.derivation.types.all.given
    
    val name = NonEmptyString("Kevin")
    Render[NonEmptyString].render(name)
    // String = Kevin
    import extras.render.Render
    
    import refined4s.Newtype
    import refined4s.modules.extras.derivation.ExtrasRender
    
    type Name = Name.Type
    object Name extends Newtype[String], ExtrasRender[String]
    
    val name = Name("Kevin")
    Render[Name].render(name)
    // String = Kevin
    import extras.render.Render
    
    import refined4s.Newtype
    
    type Name = Name.Type
    object Name extends Newtype[String]
    
    import refined4s.modules.extras.derivation.generic.auto.given
    
    val name = Name("Kevin")
    Render[Name].render(name)
    // String = Kevin

v0.8.0

31 Dec 09:41
Compare
Choose a tag to compare

0.8.0 - 2023-12-31

Changes

  • [refined4s-core] Change NewtypeBase.unapply and RefinedBase.unapply to return Some[A] instead of Option[A] (#208)

    The reason for having Some[A] as the return type of the unapply methods can be found at scala/bug#12232. 😔

v0.7.0

30 Dec 05:03
Compare
Choose a tag to compare

0.7.0 - 2023-12-30

Changes

  • [refined4s-cats] Rename validateAs in refined4s.modules.cats.syntax to refinedNewtypeNec (#182)

  • [refined4s-core] Move toValue from refined4s.syntax to refined4s.NewtypeBase (#186)

    So with the given following code,

    import refined4s.*
    import refined4s.types.all.*
    
    type Name = Name.Type
    object Name extends Newtype[NonEmptyString]
    

    the following is possible without importing any syntax.

    val name = Name(NonEmptyString("Kevin"))
    name.toValue
    // String = "Kevin"

New Features

  • [refined4s-cats] Add refinedNewtypeNel in refined4s.modules.cats.syntax (#184)

    import refined4s.*
    import refined4s.types.all.*
    
    import refined4s.modules.cats.syntax.*
    
    type Name = Name.Type
    object Name extends Newtype[NonEmptyString]
    
    "Kevin".refinedNewtypeNel[Name]
    // EitherNel[String, Name] = Right(Name(NonEmptyString("Kevin")))
    
    "".refinedNewtypeNel[Name]
    // EitherNel[String, Name] = Left(NonEmptyList("Failed to create Name: Invalid value: []. It has to be a non-empty String but got \"\"))

  • [refined4s-cats] Add validateAs in refined4s.modules.cats.syntax to validate a value and return Validated (#188)

    import refined4s.*
    import refined4s.types.all.*
    
    import refined4s.modules.cats.syntax.*
    
    type Name = Name.Type
    object Name extends Newtype[NonEmptyString]
    
    "Kevin".validateAs[Name]
    // Validated[String, Name] = Valid(Name(NonEmptyString("Kevin")))
    
    "".validateAs[Name]
    // Validated[String, Name] = Invalid("Failed to create Name: Invalid value: []. It has to be a non-empty String but got \"\")

  • [refined4s-cats] Add validateNecAs in refined4s.modules.cats.syntax to validate a value and return ValidatedNec (#189)

    import refined4s.*
    import refined4s.types.all.*
    
    import refined4s.modules.cats.syntax.*
    
    type Name = Name.Type
    object Name extends Newtype[NonEmptyString]
    
    "Kevin".validateNecAs[Name]
    // ValidatedNec[String, Name] = Valid(Name(NonEmptyString("Kevin")))
    
    "".validateNecAs[Name]
    // ValidatedNec[String, Name] = Invalid(NonEmptyChain("Failed to create Name: Invalid value: []. It has to be a non-empty String but got \"\"))

  • [refined4s-cats] Add validateNelAs in refined4s.modules.cats.syntax to validate a value and return ValidatedNel (#190)

    import refined4s.*
    import refined4s.types.all.*
    
    import refined4s.modules.cats.syntax.*
    
    type Name = Name.Type
    object Name extends Newtype[NonEmptyString]
    
    "Kevin".validateNelAs[Name]
    // ValidatedNel[String, Name] = Valid(Name(NonEmptyString("Kevin")))
    
    "".validateNelAs[Name]
    // ValidatedNel[String, Name] = Invalid(NonEmptyList("Failed to create Name: Invalid value: []. It has to be a non-empty String but got \"\"))

  • [refined4s-cats] Add derivedOrder to have the instance of Order[A] derived from Coercible[A, B] and Order[B] (#194)

    Given

    import refined4s.*
    
    type MyNum = MyNum.Type
    object MyNum extends Newtype[Int]

    it can be

    import cats.*
    
    val n1 = MyNum(1)
    val n2 = MyNum(2)
    
    Order[MyNum].compare(n1, n2)
    // Int = -1

  • [refined4s-core] Add CanBeOrdered for providing Ordering and Conversion[Type, Ordered[Type]] (#196)

    import refined4s.*
    
    type MyNum = MyNum.Type
    object MyNum extends Newtype[Int]
    val input1 = MyNum(1)
    val input2 = MyNum(2)
    
    Ordering[MyNum].compare(input1, input2)
    // Int = -1
    
    (input1: Ordered[MyNum]).compare(input2)
    // Int = -1

  • [refined4s-core] Make NonEmptyString CanBeOrdered to have Ordering[NonEmptyString] and Conversion[NonEmptyString, Ordered[NonEmptyString]] (#198)

  • [refined4s-cats] Add CatsOrder (#203)
    import refined4s.*
    
    type MyNum = MyNum.Type
    object MyNum extends Newtype[Int], CatsOrder[Int]
    import cats.*
    val myNum1 = NyNum(1)
    val myNum2 = NyNum(2)
    
    Order[MyNum].compare(myNum1, myNum1)
    // Int = 0
    
    Order[MyNum].compare(myNum1, myNum2)
    // Int = -1
    
    Order[MyNum].compare(myNum2, myNum1)
    // Int = 1

Internal Changes

  • [refined4s-core] Replace Ordering and Conversion[Type, Ordered[Type]] for numeric types with CanBeOrdered (#199)

v0.6.0

28 Dec 05:41
Compare
Choose a tag to compare

0.6.0 - 2023-12-28

Changes

  • All modules: importing derivation.instances.given can cause an issue as it overrides all type-classes defined in the companion objects (#163)
    • [refined4s-cats] Add explicit Eq and Show for pre-defined types (#171)

      • Now it has refined4s.modules.cats.derivation.types.all for the all pre-defined types (e.g. NegInt, PosInt, NonEmptyString, etc.)
      • refined4s.modules.cats.derivation.instances => refined4s.modules.cats.derivation.generic.auto
      • refined4s.modules.cats.derivation.instances.contraCoercible is moved to refined4s.modules.cats.syntax
    • [refined4s-circe] Add explicit Encoder and Decoder for pre-defined types (#166)

    • [refined4s-pureconfig] Add explicit ConfigReader and ConfigWriter for pre-defined types (#172)

    • [refined4s-doobie] Add explicit Get and Put for pre-defined types (#173)


  • [refined4s-core] Keep only all object for pre-defined types and remove all the others (#168)

    So this will be the only import available for using pre-defined types

    import refined4s.types.all.*

    The following ones have been removed.

    import refined4s.types.numeric.*
    import refined4s.types.strings.*
    import refined4s.types.network.*

  • Rename derived type classes - some of them have a naming conflict issue (#165)