Giter VIP home page Giter VIP logo

vivalidi's Introduction

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

vivalidi's People

Contributors

kubukoz avatar scala-steward avatar tues avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

vivalidi's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.