vivalidi

Elegant, effect-agnostic validations for Scala DTOs

License

License

GroupId

GroupId

com.kubukoz
ArtifactId

ArtifactId

vivalidi_2.12
Last Version

Last Version

0.6.0
Release Date

Release Date

Type

Type

jar
Description

Description

vivalidi
Elegant, effect-agnostic validations for Scala DTOs
Project URL

Project URL

https://github.com/kubukoz/vivalidi
Project Organization

Project Organization

com.kubukoz
Source Code Management

Source Code Management

https://github.com/kubukoz/vivalidi

Download vivalidi_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.kubukoz/vivalidi_2.12/ -->
<dependency>
    <groupId>com.kubukoz</groupId>
    <artifactId>vivalidi_2.12</artifactId>
    <version>0.6.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.kubukoz/vivalidi_2.12/
implementation 'com.kubukoz:vivalidi_2.12:0.6.0'
// https://jarcasting.com/artifacts/com.kubukoz/vivalidi_2.12/
implementation ("com.kubukoz:vivalidi_2.12:0.6.0")
'com.kubukoz:vivalidi_2.12:jar:0.6.0'
<dependency org="com.kubukoz" name="vivalidi_2.12" rev="0.6.0">
  <artifact name="vivalidi_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.kubukoz', module='vivalidi_2.12', version='0.6.0')
)
libraryDependencies += "com.kubukoz" % "vivalidi_2.12" % "0.6.0"
[com.kubukoz/vivalidi_2.12 "0.6.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8
com.chuusai : shapeless_2.12 jar 2.3.3
org.typelevel : cats-core_2.12 jar 2.0.0

test (4)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.8
org.scalacheck : scalacheck_2.12 jar 1.14.2
org.typelevel : cats-effect_2.12 jar 2.0.0
org.typelevel : cats-effect-laws_2.12 jar 2.0.0

Project Modules

There are no modules declared in this project.

vivalidi [abandoned]

Build Status Latest version Maven Central License

This project is not actively developed. Use Parallel from cats.

A crazy man's effect-agnostic validations for Scala DTOs. Mostly extra syntax for cats' parMapN that's less red-squiggly in IntelliJ IDEA.

Warning: this library is as experimental as they come (it doesn't even have a logo yet). You're highly discouraged from using it in production, although you might want to check it out in side projects or contribute to the upcoming planning for a more stable API.

SBT dependency

"com.kubukoz" %% "vivalidi" % "x.x.x"

Replace x.x.x with the version you want (the latest non-snapshot release version can be seen on the top of this README). The library is cross-compiled to Scala 2.12 and Scala.js - for the latter, replace %% with %%%.

Usage

Coming soon - until then, please enjoy this example from tests:

import vivalidi.Vivalidi, vivalidi.syntax.all._
type EitherNelT[F[_], E, T] = EitherT[F, NonEmptyList[E], T]
type E[A] = EitherNelT[IO, String, A]

val validation: Person => EitherNelT[IO, String, Person] = Vivalidi[Person, E].init
  .sync(_.id)(_ => "wrong id".leftNel[Long])
  .just(_.name)
  .async(_.age)(_ => "wrong age".leftNel[Int].liftTo[E])
  .to[Person]
  .run

val person = Person(1, "hello", 21)

validation(person).value.unsafeRunSync()

tl;dr CreateV[_] : Applicative - so far the validators (e.g. validateLength, a custom function taking String and returning CreateV[String]) are responsible for raising errors, but in the future there might be no type parameter for errors, just an appropriate MonadError context bound. F[_] is just an applicative (like Future), and TransactionToCreate is the input type (which toCreate matches).

FAQ

  1. Can I use this in production?

I mean you can, but you'll be on your own, as the API will change tens of times before it gets anywhere near stable

  1. Does this have any external dependencies?

Yes, there's a direct dependency on cats-core and shapeless.

  1. Tests?

lmao

Versions

Version
0.6.0
0.5.1
0.5.0
0.4.0
0.3.0
0.1.0
0.0.9
0.0.8
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1