用于验证对象的 DSL Valiktor

码农软件 · 软件分类 · 其他开发相关 · 2019-10-16 09:12:24

软件介绍

Valiktor 是一个类型安全、功能强大且可扩展的流畅 DSL,用于验证 Kotlin 中的对象。

安装

Gradle (Groovy):

compile 'org.valiktor:valiktor-core:0.3.1'

Gradle (Kotlin DSL):

compile("org.valiktor:valiktor-core:0.3.1")

Maven:

<dependency>
  <groupId>org.valiktor</groupId>
  <artifactId>valiktor-core</artifactId>
  <version>0.3.1</version>
</dependency>
  • For install other modules, see Modules.

开始使用

import org.valiktor.validate
import org.valiktor.functions.*

data class Employee(val id: Int, val name: String, val email: String) {
    init {
        validate(this) {
            validate(Employee::id).isPositive()
            validate(Employee::name).isNotBlank().hasSize(min = 1, max = 80)
            validate(Employee::email).isNotBlank().hasSize(min = 1, max = 50).isEmail()
        }
    }
}

本文地址:https://codercto.com/soft/d/16865.html

About Face 3

About Face 3

Alan Cooper、Robert Reimann、David Cronin / John Wiley & Sons / 2007-5-15 / GBP 28.99

* The return of the authoritative bestseller includes all new content relevant to the popularization of how About Face maintains its relevance to new Web technologies such as AJAX and mobile platforms......一起来看看 《About Face 3》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具