Skip to content
validation api extracted from play
Branch: master
Clone or download
Latest commit e7d0df1 Oct 31, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
date-tests/src/test/scala Adding a Rule, a Writer and the tests for java.time.LocalDate ZonedDate Mar 9, 2017
docs/src/main/tut Update dependencies Aug 31, 2018
play-scalajs-example - Support for Scala 2.12 Feb 6, 2017
project Update dependencies Aug 31, 2018
scripts v2.0 Jun 27, 2016
validation-core/src Update dependencies Aug 31, 2018
validation-delimited/src Add trait to Rules/Writes for easy override Oct 14, 2016
validation-form/src Update dependencies Aug 31, 2018
validation-jsjson/src Update dependencies Aug 31, 2018
validation-jsonast Update dependencies Aug 31, 2018
validation-xml/src Update dependencies Aug 31, 2018
.gitignore v2.0 Jun 27, 2016
.travis.yml v2.0 Jun 27, 2016 publish version doc Aug 4, 2016 - Support for Scala 2.12 Feb 6, 2017
build.sbt Update dependencies Aug 31, 2018
version.sbt publish 2.1.1 Nov 8, 2017

The unified data validation library

Travis Coverage Status Maven Scala.js Gitter


The unified validation API aims to provide a comprehensive toolkit to validate data from any format against user defined rules, and transform them to other types.

Basically, assuming you have this:

import play.api.libs.json._
import jto.validation._

case class Person(name: String, age: Int, lovesChocolate: Boolean)

val json = Json.parse("""{
  "name": "Julien",
  "age": 28,
  "lovesChocolate": true

implicit val personRule = {
  import jto.validation.playjson.Rules._
  Rule.gen[JsValue, Person]

It can do this:

scala> personRule.validate(json)
res0: jto.validation.VA[Person] = Valid(Person(Julien,28,true))


It's also a unification of play's Form Validation API, and its Json validation API.

Being based on the same concepts as play's Json validation API, it should feel very similar to any developer already working with it. The unified validation API is, rather than a totally new design, a simple generalization of those concepts.


The unified validation API is designed around a core defined in package jto.validation, and "extensions". Each extension provides primitives to validate and serialize data from / to a particular format (Json, form encoded request body, etc.). See the extensions documentation for more information.

To learn more about data validation, please consult Validation and transformation with Rule, for data serialization read Serialization with Write. If you just want to figure all this out by yourself, please see the Cookbook.

Using the validation api in your project

Add the following dependencies your build.sbt as needed:

resolvers += Resolver.sonatypeRepo("releases")

val validationVersion = "2.1.0"

libraryDependencies ++= Seq(
  "io.github.jto" %% "validation-core"      % validationVersion,
  "io.github.jto" %% "validation-playjson"  % validationVersion,
  "io.github.jto" %% "validation-jsonast"   % validationVersion,
  "io.github.jto" %% "validation-form"      % validationVersion,
  "io.github.jto" %% "validation-delimited" % validationVersion,
  "io.github.jto" %% "validation-xml"       % validationVersion
  // "io.github.jto" %%% "validation-jsjson"    % validationVersion

Play dependencies

Validation Play
2.1.x 2.6.x
2.0.x 2.5.x
1.1.x 2.4.x
1.0.2 2.3.x


Documentation is here


You can’t perform that action at this time.