Author: hardy.ferentschik
Date: 2009-09-03 07:59:18 -0400 (Thu, 03 Sep 2009)
New Revision: 17473
Removed:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/checkconstraints.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml
Log:
HV-220
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-09-03
11:58:50 UTC (rev 17472)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-09-03
11:59:18 UTC (rev 17473)
@@ -103,13 +103,4 @@
<xi:include href="modules/integration.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
-
- <xi:include href="modules/extendedri.xml"
-
xmlns:xi="http://www.w3.org/2001/XInclude" />
-
- <xi:include href="modules/defineconstraints.xml"
-
xmlns:xi="http://www.w3.org/2001/XInclude" />
-
- <xi:include href="modules/checkconstraints.xml"
-
xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
Deleted:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/checkconstraints.xml
===================================================================
---
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/checkconstraints.xml 2009-09-03
11:58:50 UTC (rev 17472)
+++
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/checkconstraints.xml 2009-09-03
11:59:18 UTC (rev 17473)
@@ -1,235 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ This copyrighted material is made available to anyone wishing to use, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-
-<chapter id="validator-checkconstraints">
- <title>Using the Validator framework</title>
-
- <para>Hibernate Validator is intended to be used to implement multi-layered
- data validation, where constraints are expressed in a single place (the
- annotated domain model) and checked in various different layers of the
- application.</para>
-
- <para>This chapter will cover Hibernate Validator usage for different
- layers</para>
-
- <section id="validator-checkconstraints-db" revision="2">
- <title>Database schema-level validation</title>
-
- <para>Out of the box, Hibernate Annotations will translate the constraints
- you have defined for your entities into mapping metadata. For example, if
- a property of your entity is annotated <literal>@NotNull</literal>, its
- columns will be declared as <literal>not null</literal> in the DDL
schema
- generated by Hibernate.</para>
-
- <para>Using hbm2ddl, domain model constraints will be expressed into the
- database schema.</para>
-
- <para>If, for some reason, the feature needs to be disabled, set
- <literal>hibernate.validator.apply_to_ddl</literal> to
- <literal>false</literal>.</para>
- </section>
-
- <section id="validator-checkconstraints-orm">
- <title>ORM integration</title>
-
- <para>Hibernate Validator integrates with both Hibernate and all pure Java
- Persistence providers</para>
-
- <section id="validator-checkconstraints-orm-hibernateevent"
revision="1">
- <title>Hibernate event-based validation</title>
-
- <para>Hibernate Validator has two built-in Hibernate event listeners.
- Whenever a <literal>PreInsertEvent</literal> or
- <literal>PreUpdateEvent</literal> occurs, the listeners will verify
all
- constraints of the entity instance and throw an exception if any
- constraint is violated. Basically, objects will be checked before any
- inserts and before any updates made by Hibernate. This includes changes
- applied by cascade! This is the most convenient and the easiest way to
- activate the validation process. On constraint violation, the event will
- raise a runtime <classname>InvalidStateException</classname> which
- contains an array of <literal>InvalidValue</literal>s describing each
- failure.</para>
-
- <para>If Hibernate Validator is present in the classpath, Hibernate
- Annotations (or Hibernate EntityManager) will use it transparently. If,
- for some reason, you want to disable this integration, set
- <literal>hibernate.validator.autoregister_listeners</literal> to
- false</para>
-
- <para><note>
- <para>If the beans are not annotated with validation annotations,
- there is no runtime performance cost.</para>
- </note></para>
-
- <para>In case you need to manually set the event listeners for Hibernate
- Core, use the following configuration in
- <literal>hibernate.cfg.xml</literal>:</para>
-
- <programlisting><hibernate-configuration>
- ...
- <event type="pre-update">
- <listener
- class="org.hibernate.validator.event.ValidateEventListener"/>
- </event>
- <event type="pre-insert">
- <listener
- class="org.hibernate.validator.event.ValidateEventListener"/>
- </event>
-</hibernate-configuration></programlisting>
- </section>
-
- <section id="validator-checkconstraints-orm-jpaevent">
- <title>Java Persistence event-based validation</title>
-
- <para>Hibernate Validator is not tied to Hibernate for event based
- validation: a Java Persistence entity listener is available. Whenever an
- listened entity is persisted or updated, Hibernate Validator will verify
- all constraints of the entity instance and throw an exception if any
- constraint is violated. Basically, objects will be checked before any
- inserts and before any updates made by the Java Persistence provider.
- This includes changes applied by cascade! On constraint violation, the
- event will raise a runtime
<classname>InvalidStateException</classname>
- which contains an array of <literal>InvalidValue</literal>s describing
- each failure.</para>
-
- <para>Here is how to make a class validatable:</para>
-
- <programlisting>@Entity
-@EntityListeners( JPAValidateListener.class )
-public class Submarine {
- ...
-}</programlisting>
-
- <para><note>
- <para>Compared to the Hibernate event, the Java Persistence listener
- has two drawbacks. You need to define the entity listener on every
- validatable entity. The DDL generated by your provider will not
- reflect the constraints.</para>
- </note></para>
- </section>
- </section>
-
- <section>
- <title>Application-level validation</title>
-
- <para>Hibernate Validator can be applied anywhere in your application
- code.</para>
-
- <programlisting>ClassValidator personValidator = new ClassValidator(
Person.class );
-ClassValidator addressValidator = new ClassValidator( Address.class,
ResourceBundle.getBundle("messages", Locale.ENGLISH) );
-
-InvalidValue[] validationMessages =
addressValidator.getInvalidValues(address);</programlisting>
-
- <para>The first two lines prepare the Hibernate Validator for class
- checking. The first one relies upon the error messages embedded in
- Hibernate Validator (see <xref
- linkend="validator-defineconstraints-error" />), the second one uses a
- resource bundle for these messages. It is considered a good practice to
- execute these lines once and cache the validator instances.</para>
-
- <para>The third line actually validates the
<literal>Address</literal>
- instance and returns an array of <literal>InvalidValue</literal>s. Your
- application logic will then be able to react to the failure.</para>
-
- <para>You can also check a particular property instead of the whole bean.
- This might be useful for property per property user interaction</para>
-
- <programlisting>ClassValidator addressValidator = new ClassValidator(
Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) );
-
-//only get city property invalid values
-InvalidValue[] validationMessages = addressValidator.getInvalidValues(address,
"city");
-
-//only get potential city property invalid values
-InvalidValue[] validationMessages =
addressValidator.getPotentialInvalidValues("city",
"Paris")</programlisting>
- </section>
-
- <section>
- <title>Presentation layer validation</title>
-
- <para>When working with JSF and <productname>JBoss
Seam</productname>, one
- can triggers the validation process at the presentation layer using Seam's
- JSF tags <literal><s:validate></literal> and
- <literal><s:validateAll/></literal>, letting the
constraints be
- expressed on the model, and the violations presented in the view</para>
-
- <programlisting><h:form>
- <div>
- <h:messages/>
- </div>
- <emphasis role="bold"><s:validateAll></emphasis>
- <div>
- Country:
- <h:inputText value="#{location.country}"
required="true"/>
- </div>
- <div>
- Zip code:
- <h:inputText value="#{location.zip}"
required="true"/>
- </div>
- <div>
- <h:commandButton/>
- </div>
- <emphasis
role="bold"></s:validateAll></emphasis>
-</h:form></programlisting>
-
- <para>Going even further, and adding
<productname>Ajax4JSF</productname>
- to the loop will bring client side validation with just a couple of
- additional JSF tags, again without validation definition
- duplication.</para>
-
- <para>Check the <ulink
url="http://www.jboss.com/products/seam">JBoss
- Seam</ulink> documentation for more information.</para>
- </section>
-
- <section>
- <title>Validation informations</title>
-
- <para>As a validation information carrier, hibernate provide an array of
- <classname>InvalidValue</classname>. Each
<literal>InvalidValue</literal>
- has a buch of methods describing the individual issues.</para>
-
- <para><methodname>getBeanClass()</methodname> retrieves the failing
bean
- type</para>
-
- <para><methodname>getBean()</methodname>retrieves the failing
instance (if
- any ie not when using
- <methodname>getPotentianInvalidValues()</methodname>)</para>
-
- <para><methodname>getValue()</methodname> retrieves the failing
- value</para>
-
- <para><methodname>getMessage()</methodname> retrieves the proper
- internationalized error message</para>
-
- <para><methodname>getRootBean()</methodname> retrieves the root
bean
- instance generating the issue (useful in conjunction with
- <literal>@Valid</literal>), is null if getPotentianInvalidValues() is
- used.</para>
-
- <para><literal>getPropertyPath()</literal> retrieves the dotted
path of
- the failing property starting from the root bean</para>
- </section>
-</chapter>
\ No newline at end of file
Deleted:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml
===================================================================
---
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml 2009-09-03
11:58:50 UTC (rev 17472)
+++
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml 2009-09-03
11:59:18 UTC (rev 17473)
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ Hibernate, Relational Persistence for Idiomatic Java
- ~
- ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- ~ indicated by the @author tags or express copyright attribution
- ~ statements applied by the authors. All third-party contributions are
- ~ distributed under license by Red Hat Middleware LLC.
- ~
- ~ This copyrighted material is made available to anyone wishing to use, modify,
- ~ copy, or redistribute it subject to the terms and conditions of the GNU
- ~ Lesser General Public License, as published by the Free Software Foundation.
- ~
- ~ This program is distributed in the hope that it will be useful,
- ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- ~ for more details.
- ~
- ~ You should have received a copy of the GNU Lesser General Public License
- ~ along with this distribution; if not, write to:
- ~ Free Software Foundation, Inc.
- ~ 51 Franklin Street, Fifth Floor
- ~ Boston, MA 02110-1301 USA
- -->
-
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-
- <chapter id="validator-extendedri">
- <title>Extended features of Bean Validation reference
implementation</title>
-
-<section id="validator-extendedri-constraintannotations"
- revision="1">
- <title>Additional constraint annotations</title>
-</section>
-
- </chapter>
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
===================================================================
---
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml 2009-09-03
11:58:50 UTC (rev 17472)
+++
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml 2009-09-03
11:59:18 UTC (rev 17473)
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
@@ -23,9 +22,184 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="validator-checkconstraints">
+ <title>Integration with other frameworks</title>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+ <para>Hibernate Validator is intended to be used to implement multi-layered
+ data validation, where constraints are expressed in a single place (the
+ annotated domain model) and checked in various different layers of the
+ application.</para>
- <chapter id="validator-integration">
- <title>Integrating Bean Validation RI with other frameworks</title>
- </chapter>
+ <para>This chapter will cover Hibernate Validator usage for different
+ layers</para>
+
+ <section id="validator-checkconstraints-db" revision="2">
+ <title>Database schema-level validation</title>
+
+ <para>Out of the box, Hibernate Annotations will translate the constraints
+ you have defined for your entities into mapping metadata. For example, if
+ a property of your entity is annotated <literal>@NotNull</literal>, its
+ columns will be declared as <literal>not null</literal> in the DDL
schema
+ generated by Hibernate.</para>
+
+ <para>Using hbm2ddl, domain model constraints will be expressed into the
+ database schema.</para>
+
+ <para>If, for some reason, the feature needs to be disabled, set
+ <literal>hibernate.validator.apply_to_ddl</literal> to
+ <literal>false</literal>.</para>
+ </section>
+
+ <section id="validator-checkconstraints-orm">
+ <title>ORM integration</title>
+
+ <para>Hibernate Validator integrates with both Hibernate and all pure Java
+ Persistence providers</para>
+
+ <section id="validator-checkconstraints-orm-hibernateevent"
revision="1">
+ <title>Hibernate event-based validation</title>
+
+ <para>Hibernate Validator has two built-in Hibernate event listeners.
+ Whenever a <literal>PreInsertEvent</literal> or
+ <literal>PreUpdateEvent</literal> occurs, the listeners will verify
all
+ constraints of the entity instance and throw an exception if any
+ constraint is violated. Basically, objects will be checked before any
+ inserts and before any updates made by Hibernate. This includes changes
+ applied by cascade! This is the most convenient and the easiest way to
+ activate the validation process. On constraint violation, the event will
+ raise a runtime <classname>InvalidStateException</classname> which
+ contains an array of <literal>InvalidValue</literal>s describing each
+ failure.</para>
+
+ <para>If Hibernate Validator is present in the classpath, Hibernate
+ Annotations (or Hibernate EntityManager) will use it transparently. If,
+ for some reason, you want to disable this integration, set
+ <literal>hibernate.validator.autoregister_listeners</literal> to
+ false</para>
+
+ <para><note>
+ <para>If the beans are not annotated with validation annotations,
+ there is no runtime performance cost.</para>
+ </note></para>
+
+ <para>In case you need to manually set the event listeners for Hibernate
+ Core, use the following configuration in
+ <literal>hibernate.cfg.xml</literal>:</para>
+
+ <programlisting><hibernate-configuration>
+ ...
+ <event type="pre-update">
+ <listener
+ class="org.hibernate.validator.event.ValidateEventListener"/>
+ </event>
+ <event type="pre-insert">
+ <listener
+ class="org.hibernate.validator.event.ValidateEventListener"/>
+ </event>
+</hibernate-configuration></programlisting>
+ </section>
+
+ <section id="validator-checkconstraints-orm-jpaevent">
+ <title>Java Persistence event-based validation</title>
+
+ <para>Hibernate Validator is not tied to Hibernate for event based
+ validation: a Java Persistence entity listener is available. Whenever an
+ listened entity is persisted or updated, Hibernate Validator will verify
+ all constraints of the entity instance and throw an exception if any
+ constraint is violated. Basically, objects will be checked before any
+ inserts and before any updates made by the Java Persistence provider.
+ This includes changes applied by cascade! On constraint violation, the
+ event will raise a runtime
<classname>InvalidStateException</classname>
+ which contains an array of <literal>InvalidValue</literal>s describing
+ each failure.</para>
+
+ <para>Here is how to make a class validatable:</para>
+
+ <programlisting>@Entity
+@EntityListeners( JPAValidateListener.class )
+public class Submarine {
+ ...
+}</programlisting>
+
+ <para><note>
+ <para>Compared to the Hibernate event, the Java Persistence listener
+ has two drawbacks. You need to define the entity listener on every
+ validatable entity. The DDL generated by your provider will not
+ reflect the constraints.</para>
+ </note></para>
+ </section>
+ </section>
+
+ <section>
+ <title>Application-level validation</title>
+
+ <para>Hibernate Validator can be applied anywhere in your application
+ code.</para>
+
+ <programlisting>ClassValidator personValidator = new ClassValidator(
Person.class );
+ClassValidator addressValidator = new ClassValidator( Address.class,
ResourceBundle.getBundle("messages", Locale.ENGLISH) );
+
+InvalidValue[] validationMessages =
addressValidator.getInvalidValues(address);</programlisting>
+
+ <para>The first two lines prepare the Hibernate Validator for class
+ checking. The first one relies upon the error messages embedded in
+ Hibernate Validator (see <xref
+ linkend="validator-defineconstraints-error" />), the second one uses a
+ resource bundle for these messages. It is considered a good practice to
+ execute these lines once and cache the validator instances.</para>
+
+ <para>The third line actually validates the
<literal>Address</literal>
+ instance and returns an array of <literal>InvalidValue</literal>s. Your
+ application logic will then be able to react to the failure.</para>
+
+ <para>You can also check a particular property instead of the whole bean.
+ This might be useful for property per property user interaction</para>
+
+ <programlisting>ClassValidator addressValidator = new ClassValidator(
Address.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) );
+
+//only get city property invalid values
+InvalidValue[] validationMessages = addressValidator.getInvalidValues(address,
"city");
+
+//only get potential city property invalid values
+InvalidValue[] validationMessages =
addressValidator.getPotentialInvalidValues("city",
"Paris")</programlisting>
+ </section>
+
+ <section>
+ <title>Presentation layer validation</title>
+
+ <para>When working with JSF and <productname>JBoss
Seam</productname>, one
+ can triggers the validation process at the presentation layer using Seam's
+ JSF tags <literal><s:validate></literal> and
+ <literal><s:validateAll/></literal>, letting the
constraints be
+ expressed on the model, and the violations presented in the view</para>
+
+ <programlisting><h:form>
+ <div>
+ <h:messages/>
+ </div>
+ <emphasis role="bold"><s:validateAll></emphasis>
+ <div>
+ Country:
+ <h:inputText value="#{location.country}"
required="true"/>
+ </div>
+ <div>
+ Zip code:
+ <h:inputText value="#{location.zip}"
required="true"/>
+ </div>
+ <div>
+ <h:commandButton/>
+ </div>
+ <emphasis
role="bold"></s:validateAll></emphasis>
+</h:form></programlisting>
+
+ <para>Going even further, and adding
<productname>Ajax4JSF</productname>
+ to the loop will bring client side validation with just a couple of
+ additional JSF tags, again without validation definition
+ duplication.</para>
+
+ <para>Check the <ulink
url="http://www.jboss.com/products/seam">JBoss
+ Seam</ulink> documentation for more information.</para>
+ </section>
+</chapter>
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
===================================================================
---
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-09-03
11:58:50 UTC (rev 17472)
+++
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-09-03
11:59:18 UTC (rev 17473)
@@ -190,7 +190,7 @@
<para>When using property level constraints property access strategy is
used to access the value to be validated. This means the bean validation
- provider accesses the state via the property accessor method. </para>
+ provider accesses the state via the property accessor method.</para>
<para>Generally it is recommended to stick either to field
<emphasis>or</emphasis> property annotation within one class. It is
not
@@ -383,7 +383,7 @@
the <classname>Person</classname> objects contained in the
<property>passengers</property> list has a
<code>null</code> name.<note>
<para><classname>null</classname> values are getting ignored
when
- validating object graphs. </para>
+ validating object graphs.</para>
</note></para>
</section>
</section>
@@ -420,7 +420,7 @@
Validator validator = factory.getValidator();
</programlisting>We will learn more about
<classname>MessageInterpolator</classname> and
- <classname>TraversableResolver</classname> in later chapters.
</para>
+ <classname>TraversableResolver</classname> in later
chapters.</para>
<para>Last but not least you can ask for a Configuration object of a
specific Bean Validation provider. This is useful if you have more than
@@ -491,7 +491,7 @@
<para>With help of the
<methodname>validateProperty()</methodname> a
single named property of a given object can be validated. The property
name is the JavaBeans property name. @Valid is not honored by this
- method. </para>
+ method.</para>
<example>
<title>Usage of
@@ -623,7 +623,7 @@
<methodname>validateValue</methodname>. All constraints belonging to the
targeted group are applied during the Section 3.5. When more than one
group is requested, the order in which the groups are evaluated is not
- deterministic. </para>
+ deterministic.</para>
<section revision="1">
<title>Group sequences</title>
@@ -635,23 +635,26 @@
<section id="validator-defineconstraints-builtin"
revision="2">
<title>Built-in constraints</title>
- <para>Hibernate Validator comes with some built-in constraints, which
- covers some basic data checks. As we'll see later, you're not limited to
- them, you can literally in a minute write your own constraints.</para>
+ <para>Hibernate Validator implements all of the constraints specified in
+ Bean Validation and also includes some custom constraints. As we'll see
+ later, you're not limited to them, you can literally in a minute write
+ your own constraints.</para>
<table>
<title>Built-in constraints</title>
- <tgroup cols="4">
- <colspec align="center" />
+ <tgroup cols="5">
+ <colspec align="left" />
<thead>
<row>
<entry>Annotation</entry>
+ <entry>Part of Bean Validation Specification</entry>
+
<entry>Apply on</entry>
- <entry>Runtime checking</entry>
+ <entry>Use</entry>
<entry>Hibernate Metadata impact</entry>
</row>
@@ -659,192 +662,233 @@
<tbody>
<row>
- <entry>@Length(min=, max=)</entry>
+ <entry>@AssertFalse</entry>
- <entry>property (String)</entry>
+ <entry>yes</entry>
- <entry>check if the string length match the range</entry>
+ <entry>field/property</entry>
- <entry>Column length will be set to max</entry>
+ <entry>check that the annotated element is
+ <constant>false</constant>.</entry>
+
+ <entry>none</entry>
</row>
<row>
- <entry>@Max(value=)</entry>
+ <entry>@AssertTrue</entry>
- <entry>property (numeric or string representation of a
- numeric)</entry>
+ <entry>yes</entry>
- <entry>check if the value is less than or equals to max</entry>
+ <entry>field/property</entry>
- <entry>Add a check constraint on the column</entry>
+ <entry>check that the annotated element is
+ <constant>true</constant>.</entry>
+
+ <entry>none</entry>
</row>
<row>
- <entry>@Min(value=)</entry>
+ <entry>@DecimalMax(value=)</entry>
- <entry>property (numeric or string representation of a
- numeric)</entry>
+ <entry>yes</entry>
- <entry>check if the value is more than or equals to min</entry>
+ <entry>field/property. Supported types are
+ <classname>BigDecimal</classname>,
+ <classname>BigInteger</classname>,
<classname>String</classname>,
+ <classname>byte</classname>,
<classname>short</classname>,
+ <classname>int</classname>,
<classname>long</classname> and the
+ respective warppers of the primtive types. </entry>
- <entry>Add a check constraint on the column</entry>
+ <entry>The annotated element must be a number whose value must be
+ lower or equal to the specified maximum. The parameter value is
+ the string representation of the max value according to the
+ <classname>BigDecimal</classname> string
representation.</entry>
+
+ <entry>?</entry>
</row>
<row>
- <entry>@NotNull</entry>
+ <entry>@DecimalMin(value=)</entry>
- <entry>property</entry>
+ <entry>yes</entry>
- <entry>check if the value is not null</entry>
+ <entry>field/property. Supported types are
+ <classname>BigDecimal</classname>,
+ <classname>BigInteger</classname>,
<classname>String</classname>,
+ <classname>byte</classname>,
<classname>short</classname>,
+ <classname>int</classname>,
<classname>long</classname> and the
+ respective warppers of the primtive types.</entry>
- <entry>Column(s) are not null</entry>
+ <entry>The annotated element must be a number whose value must be
+ higher or equal to the specified maximum. The parameter value is
+ the string representation of the min value according to the
+ <classname>BigDecimal</classname> string
representation.</entry>
+
+ <entry>?</entry>
</row>
<row>
- <entry>@NotEmpty</entry>
+ <entry>@Digits(integer=, fraction=)</entry>
- <entry>property</entry>
+ <entry>yes</entry>
- <entry>check if the string is not null nor empty. Check if the
- connection is not null nor empty</entry>
+ <entry>field/property. Supported types are
+ <classname>BigDecimal</classname>,
+ <classname>BigInteger</classname>,
<classname>String</classname>,
+ <classname>byte</classname>,
<classname>short</classname>,
+ <classname>int</classname>,
<classname>long</classname> and the
+ respective warppers of the primtive types. </entry>
- <entry>Column(s) are not null (for String)</entry>
- </row>
+ <entry>Check whether the property is a number having up to
+ <literal>integer</literal> digits and
<literal>fraction</literal>
+ fractional digits.</entry>
- <row>
- <entry>@Past</entry>
-
- <entry>property (date or calendar)</entry>
-
- <entry>check if the date is in the past</entry>
-
- <entry>Add a check constraint on the column</entry>
+ <entry>Define column precision and scale.</entry>
</row>
<row>
<entry>@Future</entry>
- <entry>property (date or calendar)</entry>
+ <entry>yes</entry>
- <entry>check if the date is in the future</entry>
+ <entry>field/property. Supported types are
+ <classname>java.util.Date</classname> and
+ <classname>java.util.Calendar</classname>.</entry>
+ <entry>Checks whether the annotated date is in the
future.</entry>
+
<entry>none</entry>
</row>
<row>
- <entry>@Pattern(regex="regexp", flag=) or @Patterns(
- {@Pattern(...)} )</entry>
+ <entry>@Length(min=, max=)</entry>
- <entry>property (string)</entry>
+ <entry>no</entry>
- <entry>check if the property match the regular expression given a
- match flag (see <classname>java.util.regex.Pattern </classname>
- )</entry>
+ <entry>field/property. Needs to be a string.</entry>
- <entry>none</entry>
+ <entry>Validate that the annotated string is between
+ <parameter>min</parameter> and
<parameter>max</parameter>
+ included.</entry>
+
+ <entry>Column length will be set to max.</entry>
</row>
<row>
- <entry>@Range(min=, max=)</entry>
+ <entry>@Max(value=)</entry>
- <entry>property (numeric or string representation of a
- numeric)</entry>
+ <entry>yes</entry>
- <entry>check if the value is between min and max
- (included)</entry>
+ <entry>field/property. Supported types are
+ <classname>BigDecimal</classname>,
+ <classname>BigInteger</classname>,
<classname>String</classname>,
+ <classname>byte</classname>,
<classname>short</classname>,
+ <classname>int</classname>,
<classname>long</classname> and the
+ respective warppers of the primtive types.</entry>
- <entry>Add a check constraint on the column</entry>
+ <entry>Checks whether the annoated value is less than or equal to
+ the specified maximum.</entry>
+
+ <entry>Add a check constraint on the column.</entry>
</row>
<row>
- <entry>@Size(min=, max=)</entry>
+ <entry>@Min(value=)</entry>
- <entry>property (array, collection, map)</entry>
+ <entry>yes</entry>
- <entry>check if the element size is between min and max
- (included)</entry>
+ <entry>field/property. Supported types are
+ <classname>BigDecimal</classname>,
+ <classname>BigInteger</classname>,
<classname>String</classname>,
+ <classname>byte</classname>,
<classname>short</classname>,
+ <classname>int</classname>,
<classname>long</classname> and the
+ respective warppers of the primtive types.</entry>
- <entry>none</entry>
+ <entry>Check whether the annoated value is higher than or equal to
+ the specified minimum.</entry>
+
+ <entry>Add a check constraint on the column.</entry>
</row>
<row>
- <entry>@AssertFalse</entry>
+ <entry>@NotNull</entry>
- <entry>property</entry>
+ <entry>yes</entry>
- <entry>check that the method evaluates to false (useful for
- constraints expressed in code rather than annotations)</entry>
+ <entry>field/property</entry>
- <entry>none</entry>
+ <entry>Check that the annoated value is not
+ <constant>null.</constant></entry>
+
+ <entry>Column(s) are not null.</entry>
</row>
<row>
- <entry>@AssertTrue</entry>
+ <entry>@NotEmpty</entry>
- <entry>property</entry>
+ <entry>no</entry>
- <entry>check that the method evaluates to true (useful for
- constraints expressed in code rather than annotations)</entry>
+ <entry>field/property. Needs to be a string.</entry>
- <entry>none</entry>
+ <entry>Check if the string is not <constant>null</constant>
nor
+ empty. </entry>
+
+ <entry>Column(s) are not null (for String).</entry>
</row>
<row>
- <entry>@Valid</entry>
+ <entry>@Past</entry>
- <entry>property (object)</entry>
+ <entry>yes</entry>
- <entry>perform validation recursively on the associated object. If
- the object is a Collection or an array, the elements are validated
- recursively. If the object is a Map, the value elements are
- validated recursively.</entry>
+ <entry>field/property. Supported types are
+ <classname>java.util.Date</classname> and
+ <classname>java.util.Calendar</classname>.</entry>
+ <entry>Checks whether the annotated date is in the past.</entry>
+
<entry>none</entry>
</row>
<row>
- <entry>@Email</entry>
+ <entry>@Pattern(regex=, flag=)</entry>
- <entry>property (String)</entry>
+ <entry>yes</entry>
- <entry>check whether the string is conform to the email address
- specification</entry>
+ <entry>field/property. Needs to be a string.</entry>
+ <entry>Check if the annotated string match the regular
+ expression.</entry>
+
<entry>none</entry>
</row>
<row>
- <entry>@CreditCardNumber</entry>
+ <entry>@Size(min=, max=)</entry>
- <entry>property (String)</entry>
+ <entry>yes</entry>
- <entry>check whether the string is a well formated credit card
- number (derivative of the Luhn algorithm)</entry>
+ <entry>field/property. Supported types are
+ <classname>String</classname>,
<classname>Collection</classname>,
+ <classname>Map</classname> and
+ <classname>arrays</classname>.</entry>
+ <entry>Check if the annotated element size is between min and max
+ (inclusive).</entry>
+
<entry>none</entry>
</row>
<row>
- <entry>@Digits</entry>
+ <entry>@Valid</entry>
- <entry>property (numeric or string representation of a
- numeric)</entry>
+ <entry>yes</entry>
- <entry>check whether the property is a number having up to
- <literal>integerDigits</literal> integer digits and
- <literal>fractionalDigits</literal> fractonal
digits</entry>
+ <entry>field/property</entry>
- <entry>define column precision and scale</entry>
- </row>
+ <entry>Perform validation recursively on the associated
+ object.</entry>
- <row>
- <entry>@EAN</entry>
-
- <entry>property (string)</entry>
-
- <entry>check whether the string is a properly formated EAN or
- UPC-A code</entry>
-
<entry>none</entry>
</row>
</tbody>
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml
===================================================================
---
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml 2009-09-03
11:58:50 UTC (rev 17472)
+++
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml 2009-09-03
11:59:18 UTC (rev 17473)
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
@@ -23,9 +22,8 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-
- <chapter id="validator-xmlconfiguration">
- <title>Using XML for constraint configuration</title>
- </chapter>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="validator-xmlconfiguration">
+ <title>XML configuration</title>
+</chapter>