GithubHelp home page GithubHelp logo

skepticcoder / bean-validation-scala Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bean-validation-scala/bean-validation-scala

0.0 1.0 0.0 67 KB

JSR 303 and 349 Bean Validation for Scala.

License: MIT License

Scala 94.90% Java 5.10%

bean-validation-scala's Introduction

bean-validation-scala

JSR 303 and 349 Bean Validation for Scala. This library enable validation to some Monad. (e.g. Option, Seq, etc)

Build Status Maven Central Scaladoc

Getting Started

Support Scala 2.11 and 2.12

libraryDependencies ++= Seq(
  "com.tsukaby" %% "bean-validation-scala" % "0.4.2"
)

This library has been published in the Maven central.

How to use

Step 1. Add annotations to your case class.

import javax.validation.constraints.Size

case class Person(
  @(Size@field)(min = 4)
  name: Option[String]
)

Step 2. Create validator by our library.

import com.tsukaby.bean_validation_scala.ScalaValidatorFactory

val validator = ScalaValidatorFactory.validator

Step 3. Validate a case class object.

  val obj = Person(Some("abc"))
  val violations = validator.validate(obj)

  if (violations.nonEmpty) {
    println("Violations found!")
  }

Other information.

Support annotations.

javax.validation.constraints

  • AssertFalse
  • AssertTrue
  • DecimalMax
  • DecimalMin
  • Digits
  • Future
  • Max
  • Min
  • Past
  • Pattern
  • Size

org.hibernate.validator.constraints

  • CreditCardNumber
  • EAN
  • Email
  • Length
  • LuhnCheck
  • Mod10Check
  • Mod11Check
  • NotBlank
  • NotEmpty
  • Range
  • SafeHtml
  • URL

com.tsukaby.bean_validation_scala

Original annotations.

  • AssertNone
  • AssertSome
  • ByteSize

Doesn't support annotations.

  • NotNull // What do you think I should do?
  • Null
  • ModCheck // Deprecated
  • ParameterScriptAssert
  • ScriptAssert

Contribution

I'm seeking your PR!!! I'm easy.

For example.

  • Bug fix
  • Refactoring the code.
  • Add a new feature, new annotations and others.
  • Fix my odd English texts.

License

Copyright 2015 - 2017 tsukaby.com
MIT License

bean-validation-scala's People

Contributors

gitter-badger avatar kgignatyev avatar sh0hei avatar tkawachi avatar tsukaby avatar

Watchers

 avatar

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.