About

scala-simple-validation was designed to allow in simple way validate case classes and other data structures. It provides:

  1. easy way for describing validation schema
  2. few common validators to use
  3. simple way of creating your own, custom validators
  4. designing more complex validation process - where validation depends on some specific value
  5. allow to reuse validation schemas as validators

Getting started

Add to yours build.sbt:


resolvers ++= Seq(
  Resolver.sonatypeRepo("releases"),
  Resolver.sonatypeRepo("snapshots")
)

libraryDependencies += "pl.muninn" %% "scala-simple-validation" % "0.1.2-SNAPSHOT"

Then you need to only add in your code:

import pl.muninn.simple.validation._

And you can start using it

Usage example

Simple example of how to use library

import pl.muninn.simple.validation._

 case class LoginRequest(login:String, password:String)

 val schema:ValidationSchema[LoginRequest] = createSchema { context =>
   context.field(_.login).notEmpty +
     context.field(_.password).notEmpty
 }
// schema: ValidationSchema[LoginRequest] = <function1>

 val result = schema.validate(LoginRequest("admin", "admin"))
// result: ValidationResult = Valid(a = ())

 result.isValid
// res0: Boolean = true