Java对象验证框架 OVal

码农软件 · 软件分类 · 服务框架/平台 · 2019-09-26 20:58:17

软件介绍

OVal 是一个可扩展的Java对象数据验证框架,验证的规则可以通过配置文件、Annotation、POJOs 进行设定。可以使用纯 Java 语言、JavaScript 、Groovy 、BeanShell 等进行规则的编写。

示例代码:

private static class TestEntity
{
@Min(1960)
private int year = 1977;

@Range(min=1, max=12)
private int month = 2;

@ValidateWithMethod(methodName = "isValidDay", parameterType = int.class)
private int day = 31;

private boolean isValidDay(int day)
{
GregorianCalendar cal = new GregorianCalendar();
cal.setLenient(false);
cal.set(GregorianCalendar.YEAR, year);
cal.set(GregorianCalendar.MONTH, month - 1);
cal.set(GregorianCalendar.DATE, day);
try {
cal.getTimeInMillis(); // throws IllegalArgumentException
} catch (IllegalArgumentException e) {
return false;
}
return true;
}
}

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

一站式学习C编程

一站式学习C编程

宋劲杉 / 电子工业出版社 / 2011-3 / 59.00元

《一站式学习c编程》有两条线索,一条线索是以linux平台为载体全面深入地介绍c语言的语法和程序的工作原理,另一条线索是介绍程序设计的基本思想和开发调试方法。本书分为两部分:第一部分讲解编程语言和程序设计的基本思想方法,让读者从概念上认识c语言;第二部分结合操作系统和体系结构的知识讲解程序的工作原理,让读者从本质上认识c语言。 《一站式学习c编程》适合做零基础的初学者学习c语言的第一本教材,......一起来看看 《一站式学习C编程》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具