Skip to content

Iron v1.0

Compare
Choose a tag to compare
@Iltotore Iltotore released this 13 Jul 13:10
· 248 commits to main since this release

Introdution

This is the first major release of Iron. This version includes many enhancements and new modules.

Features

Constraint results are now Either-based

This change allows functional error handling and better synergy with functional libraries like Cats.

An example of functional usage of Iron:

case class Account(username: String, email: String, password: String)

object Account {

  //Here, the Match[String] constraint isn't natively implemented in Iron and is only used as example.
  
  //Type aliases are not mandatory. They can be used for readability purpose.
  type Username = String ==> Match["^[a-zA-Z0-9]+"]
  type Email = String ==> Match["^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$"]
  //At least one upper, one lower and one number
  type Password = String ==> Match["^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])[a-zA-Z0-9]+"]
  
  def createAccount(username: Username, email: Email, password: Password): Either[IllegalValueError[String], Account] = for {
    a <- username
    b <- email
    c <- password
  } yield Account(a, b, c)
}

Constraint composition

The main module now includes basic operations to compose constraints:

  • Not[B]
  • And[B, C]
  • Or[B, C]

Extra modules

Iron now have the following modules:

Configurable evaluation behaviour

You can now configure evaluation individually using Constraint.CompileTimeOnly and Constraint.RuntimeOnly.

Future

Currently planned change are:

  • New modules for some projects like Cats and some serialization libraries (Circe, etc...)
  • A video presentation of Iron.

For further informations about installing, check the README.