Hibernate SVN: r17474 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-03 09:06:31 -0400 (Thu, 03 Sep 2009)
New Revision: 17474
Modified:
search/trunk/pom.xml
Log:
Upgraded the jdocbook plugin - now the new Hibernate style is used
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2009-09-03 11:59:18 UTC (rev 17473)
+++ search/trunk/pom.xml 2009-09-03 13:06:31 UTC (rev 17474)
@@ -190,13 +190,13 @@
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
- <version>2.1.2</version>
+ <version>2.2.0</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jdocbook-style</artifactId>
- <version>1.0.2</version>
+ <version>2.0.0</version>
<type>jdocbook-style</type>
</dependency>
</dependencies>
@@ -213,24 +213,27 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/pdf/main-pdf.xsl</stylesheetResource>
- <finalName>hibernate-search-guide.pdf</finalName>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/pdf.xsl</stylesheetResource>
+ <finalName>hibernate_reference.pdf</finalName>
</format>
<format>
<formatName>html_single</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-single.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-chunk.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
<options>
<xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <!-- needed for uri-resolvers; can be ommitted if using 'current' uri scheme -->
+ <!-- could also locate the docbook dependency and inspect its version... -->
+ <docbookVersion>1.72.0</docbookVersion>
<localeSeparator>-</localeSeparator>
- <useRelativeImageUris>true</useRelativeImageUris>
</options>
</configuration>
<executions>
14 years, 6 months
Hibernate SVN: r17473 - in validator/trunk/hibernate-validator/src/main/docbook/en-US: modules and 1 other directory.
by hibernate-commits@lists.jboss.org
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>
14 years, 6 months
Hibernate SVN: r17472 - validator/trunk/hibernate-validator.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-03 07:58:50 -0400 (Thu, 03 Sep 2009)
New Revision: 17472
Modified:
validator/trunk/hibernate-validator/pom.xml
Log:
HV-220 Changed the jdocbook plugin version to the latet version to get new Hibernate styles
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-09-02 19:30:35 UTC (rev 17471)
+++ validator/trunk/hibernate-validator/pom.xml 2009-09-03 11:58:50 UTC (rev 17472)
@@ -164,19 +164,19 @@
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
- <version>2.1.0</version>
+ <version>2.2.0</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jdocbook-style</artifactId>
- <version>1.0.2</version>
+ <version>2.0.0</version>
<type>jdocbook-style</type>
</dependency>
</dependencies>
<configuration>
<sourceDocumentName>master.xml</sourceDocumentName>
- <sourceDirectory>${basedir}/src/main/docbook/en-US</sourceDirectory>
+ <sourceDirectory>${basedir}/src/main/docbook</sourceDirectory>
<masterTranslation>en-US</masterTranslation>
<imageResource>
<directory>${basedir}/src/main/docbook/en-US/images</directory>
@@ -184,24 +184,27 @@
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/pdf/main-pdf.xsl</stylesheetResource>
- <finalName>hibernate-validator-guide.pdf</finalName>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/pdf.xsl</stylesheetResource>
+ <finalName>hibernate_reference.pdf</finalName>
</format>
<format>
<formatName>html_single</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-single.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-chunk.xsl</stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
<options>
<xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <!-- needed for uri-resolvers; can be ommitted if using 'current' uri scheme -->
+ <!-- could also locate the docbook dependency and inspect its version... -->
+ <docbookVersion>1.72.0</docbookVersion>
<localeSeparator>-</localeSeparator>
- <useRelativeImageUris>true</useRelativeImageUris>
</options>
</configuration>
<executions>
@@ -216,6 +219,11 @@
</executions>
</plugin>
<plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-style-plugin</artifactId>
+ <version>2.0.0</version>
+ </plugin>
+ <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
14 years, 6 months
Hibernate SVN: r17471 - validator/trunk/hibernate-validator/src/main/docbook/en-US/modules.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-02 15:30:35 -0400 (Wed, 02 Sep 2009)
New Revision: 17471
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
Log:
HV-220
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-02 18:50:50 UTC (rev 17470)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-09-02 19:30:35 UTC (rev 17471)
@@ -614,6 +614,17 @@
<section id="validator-usingvalidator-validationgroups" revision="1">
<title>Using groups</title>
+ <para>Groups allow you to restrict the set of constraints applied during
+ validation. This allows for example for wizard like validation where for
+ each step of the wizard only a specified subset of all defined constraints
+ get validated. The groups targeted are passed as var-args parameters to
+ <methodname>validate</methodname>,
+ <methodname>validateProperty</methodname> and
+ <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>
+
<section revision="1">
<title>Group sequences</title>
@@ -625,7 +636,7 @@
<title>Built-in constraints</title>
<para>Hibernate Validator comes with some built-in constraints, which
- covers most basic data checks. As we'll see later, you're not limited to
+ 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>
<table>
14 years, 7 months
Hibernate SVN: r17470 - validator/trunk/hibernate-validator/src/main/docbook/en-US/modules.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-02 14:50:50 -0400 (Wed, 02 Sep 2009)
New Revision: 17470
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
Log:
HV-220
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-02 15:47:47 UTC (rev 17469)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-09-02 18:50:50 UTC (rev 17470)
@@ -446,97 +446,174 @@
<title>Validator methods</title>
<para>The <classname>Validator</classname> interface contains three
- methods that can be used to validate entire objects or only single
- object properties.</para>
+ methods that can be used to validate entire object instances or only
+ single properties of an instance.</para>
<para>All of these methods return a
- <classname>Set<ConstraintViolation></classname>, which will be
+ <classname>Set<ConstraintViolation></classname>. The set will be
empty, if the validation succeeded. Otherwise a
<classname>ConstraintViolation</classname> object for each violated
- constraint will be contained.</para>
+ constraint will be added to the set.</para>
<para>All the validation methods have a var-args parameter which can be
used to specify, which validation groups shall be considered when
- performing the validation. If the parameter is not specified (as in the
- following examples) the default validation group will be used. We will
- go into more detail on the topic of validation groups in the <link
- linkend="validator-usingvalidator-validationgroups">following
- section</link>.</para>
+ performing the validation. If the parameter is not specified the default
+ validation group (<classname>javax.validation.Default</classname>) will
+ be used. We will go into more detail on the topic of validation groups
+ in <xref linkend="validator-usingvalidator-validationgroups" /></para>
<section>
- <title>validate()</title>
+ <title><methodname>validate</methodname></title>
<para>Use the <methodname>validate()</methodname> method to perform
- validation of all constraints of a given object. The following listing
- shows an example:</para>
+ validation of all constraints of a given entity instance. The
+ following listing shows an example:</para>
- <programlisting>ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ <example>
+ <title>Usage of
+ <methodname>Validator.validate()</methodname></title>
+
+ <programlisting>ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Car car = new Car(null);
-Set<ConstraintViolation<Car>> constraintViolations =
- validator.validate(car);
+Set<ConstraintViolation<Car>> constraintViolations = validator.validate(car);
assertEquals(1, constraintViolations.size());
-assertEquals(
- "may not be null", constraintViolations.iterator().next().getMessage());</programlisting>
+assertEquals("may not be null", constraintViolations.iterator().next().getMessage());</programlisting>
+ </example>
</section>
<section>
- <title>validateProperty()</title>
+ <title><methodname>validateProperty</methodname></title>
<para>With help of the <methodname>validateProperty()</methodname> a
- single named property of a given object can be validated:</para>
+ 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>
- <programlisting>Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
+ <example>
+ <title>Usage of
+ <methodname>Validator.validateProperty()</methodname></title>
+ <programlisting>Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
+
Car car = new Car(null);
-Set<ConstraintViolation<Car>> constraintViolations =
- validator.validateProperty(car, "manufacturer");
+Set<ConstraintViolation<Car>> constraintViolations = validator.validateProperty(car, "manufacturer");
assertEquals(1, constraintViolations.size());
-assertEquals(
- "may not be null", constraintViolations.iterator().next().getMessage());</programlisting>
+assertEquals("may not be null", constraintViolations.iterator().next().getMessage());</programlisting>
+
+ <para><methodname>Validator.validateProperty</methodname> is for
+ example used in the integration of Bean Validation into JSF
+ 2.</para>
+ </example>
</section>
<section>
- <title>validateValue()</title>
+ <title><methodname>validateValue</methodname></title>
<para>Using the <methodname>validateValue() </methodname>method you
can check, whether a single property of a given class can be validated
successfully, if the property had the specified value:</para>
- <programlisting>Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
+ <example>
+ <title>Usage of
+ <methodname>Validator.validateValue()</methodname></title>
-Set<ConstraintViolation<Car>> constraintViolations =
- validator.validateValue(Car.class, "manufacturer", null);
+ <programlisting>Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
+Set<ConstraintViolation<Car>> constraintViolations = validator.validateValue(Car.class, "manufacturer", null);
+
assertEquals(1, constraintViolations.size());
-assertEquals(
- "may not be null", constraintViolations.iterator().next().getMessage());</programlisting>
- </section>
+assertEquals("may not be null", constraintViolations.iterator().next().getMessage());</programlisting>
- <section>
- <title>getConstraintsForClass()</title>
-
- <para>TODO</para>
+ <para>@Valid is not honored by this method.</para>
+ </example>
</section>
</section>
<section>
- <title>Working with ConstraintViolations</title>
+ <title><classname>ConstraintViolation</classname>s explained</title>
- <para>TODO: Message interpolation?</para>
+ <para>Now it is time to have a closer look at what a failing validation
+ returns - a <classname>ConstraintViolation</classname>. Using the
+ different methods of a <classname>ConstraintViolation</classname>
+ instance a lot of useful information about the reason of the validation
+ failure can be determined.</para>
+
+ <table>
+ <title>The various <classname>ConstraintViolation</classname>
+ methods</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>Method</entry>
+
+ <entry>Usage</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getMessage()</methodname></entry>
+
+ <entry>The interpolated error message.</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getMessageTemplate()</methodname></entry>
+
+ <entry>The non-interpolated error message.</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getRootBean()</methodname></entry>
+
+ <entry>The root bean being validated.</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getRootBeanClass()</methodname></entry>
+
+ <entry>The class of the root bean being validated.</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getLeafBean()</methodname></entry>
+
+ <entry>If a bean constraint, the bean instance the constraint is
+ applied on. If a property constraint, the bean instance hosting
+ the property the constraint is applied on.</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getPropertyPath()</methodname></entry>
+
+ <entry>The property path to the value from root bean.</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getInvalidValue()</methodname></entry>
+
+ <entry>The value failing to pass the constraint.</entry>
+ </row>
+
+ <row>
+ <entry><methodname>getConstraintDescriptor()</methodname></entry>
+
+ <entry>Constraint metadata reported to fail.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
</section>
<section id="validator-usingvalidator-validationgroups" revision="1">
<title>Using groups</title>
- <para></para>
-
<section revision="1">
<title>Group sequences</title>
14 years, 7 months
Hibernate SVN: r17469 - validator/trunk/hibernate-validator/src/main/docbook/en-US/modules.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-02 11:47:47 -0400 (Wed, 02 Sep 2009)
New Revision: 17469
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
Log:
HV-220
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-09-02 13:24:17 UTC (rev 17468)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-09-02 15:47:47 UTC (rev 17469)
@@ -25,7 +25,7 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-customconstraints">
- <title>Custom constraints</title>
+ <title>Creating custom constraints</title>
<para>Though the Bean Validation API defines a whole bunch of standard
constraint annotations such as <classname>@NotNull</classname>,
@@ -251,10 +251,10 @@
<title>Using the constraint</title>
<para>Now that our first custom constraint is completed, we can use it
- in the <classname>Car</classname> class from the <link
- linkend="validator-gettingstarted">Getting started</link> chapter to
- specify that the <property>licensePlate</property> field shall only
- contain upper-case strings:</para>
+ in the <classname>Car</classname> class from the <xref
+ linkend="validator-gettingstarted" /> chapter to specify that the
+ <property>licensePlate</property> field shall only contain upper-case
+ strings:</para>
<programlisting>package com.mycompany;
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml 2009-09-02 13:24:17 UTC (rev 17468)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/defineconstraints.xml 2009-09-02 15:47:47 UTC (rev 17469)
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
@@ -22,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">
-
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-defineconstraints">
<title>Defining constraints</title>
@@ -38,7 +37,7 @@
element.</para>
</section>
- <section id="validator-defineconstraints-builtin" revision="2">
+ <section id="foo" revision="2">
<title>Built in constraints</title>
<para>Hibernate Validator comes with some built-in constraints, which
@@ -491,4 +490,4 @@
<para>The name property will be checked for nullity when the Dog bean is
validated.</para>
</section>
-</chapter>
\ No newline at end of file
+</chapter>
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2009-09-02 13:24:17 UTC (rev 17468)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2009-09-02 15:47:47 UTC (rev 17469)
@@ -105,7 +105,7 @@
and Intellij have great built-in Maven support.</para>
</note>
- <para><example xreflabel="Car-example">
+ <para><example id="example-class-car" xreflabel="">
<title>Class Car annotated with constraints</title>
<programlisting language="Java">package com.mycompany;
@@ -127,7 +127,6 @@
private int seatCount;
public Car(String manufacturer, String licencePlate, int seatCount) {
-
this.manufacturer = manufacturer;
this.licensePlate = licencePlate;
this.seatCount = seatCount;
@@ -188,7 +187,6 @@
@Test
public void manufacturerIsNull() {
-
Car car = new Car(null, "DD-AB-123", 4);
Set<ConstraintViolation<Car>> constraintViolations =
@@ -200,7 +198,6 @@
@Test
public void licensePlateTooShort() {
-
Car car = new Car("Morris", "D", 4);
Set<ConstraintViolation<Car>> constraintViolations =
@@ -212,7 +209,6 @@
@Test
public void seatCountTooLow() {
-
Car car = new Car("Morris", "DD-AB-123", 1);
Set<ConstraintViolation<Car>> constraintViolations =
@@ -224,7 +220,6 @@
@Test
public void carIsValid() {
-
Car car = new Car("Morris", "DD-AB-123", 2);
Set<ConstraintViolation<Car>> constraintViolations =
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-02 13:24:17 UTC (rev 17468)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-09-02 15:47:47 UTC (rev 17469)
@@ -25,7 +25,7 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="validator-usingvalidator">
- <title>Basic validation</title>
+ <title>Validation step by step</title>
<para>In this chapter we will see in more detail how to use Bean Validation
to validate constraints for a given entity model. We will also learn which
@@ -34,7 +34,7 @@
to add constraints to an entity.</para>
<section id="validator-usingvalidator-annotate" revision="1">
- <title>Annotating your model</title>
+ <title>Defining constraints</title>
<para>Constraints in Bean Validation are expressed via Java annotations.
In this section we show how to annotate an object model with these
@@ -42,30 +42,83 @@
constraint annotations - class-, field- and property-level
annotations.</para>
- <para><note>
- <para>Not all constraints can be placed on any of these levels. In
- fact all the default constraints defined by Bean Validation cannot be
- places at class level. The java.lang.annotation.Target annotation
- placed on the constraint annotation itself determines on which
- elements a constraint can be placed. See also </para>
- </note></para>
+ <note>
+ <para>Not all constraints can be placed on any of these levels. In fact
+ all the default constraints defined by Bean Validation cannot be places
+ at class level. The java.lang.annotation.Target annotation placed on the
+ constraint annotation itself determines on which elements a constraint
+ can be placed. See also <xref
+ linkend="validator-customconstraints" /></para>
+ </note>
<section>
<title id="validator-usingvalidator-classlevel">Class-level
- annotations</title>
+ constraints</title>
- <para>TODO</para>
+ <para>When a constraint annotation is placed on class level the class
+ instance itself passed to the
+ <classname>ConstraintValidator</classname>. Class level constraints are
+ useful if it is necessary to inspect more than a single property of the
+ class to validate it or if a correlation between different state
+ variables has to be evaluated. In the following example we add the
+ properties <property>horsePower</property> and
+ <property>kiloWatt</property> to the class <classname>Car</classname>.
+ We also add the constraint ValidCar to the class itself. We will later
+ see how we can actually create this custom constraint (see <xref
+ linkend="validator-customconstraints" />). For now we can just assume
+ that this constraints will for example ensure that the value for
+ <property>kiloWatt</property> is 0.7456 *
+ <property>horsePower</property>.</para>
+
+ <para><example xreflabel="Car-example">
+ <title>Class Car with added horsePower and killoWatt
+ properties</title>
+
+ <programlisting language="Java">package com.mycompany;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+<emphasis role="bold">@ValidCar</emphasis>
+public class Car {
+
+ <emphasis role="bold">@NotNull</emphasis>
+ private String manufacturer;
+
+ <emphasis role="bold">@NotNull</emphasis>
+ <emphasis role="bold">@Size(min = 2, max = 14)</emphasis>
+ private String licensePlate;
+
+ <emphasis role="bold">@Min(2)</emphasis>
+ private int seatCount;
+
+ private int horsePower;
+
+ private double kiloWatt;
+
+ public Car(String manufacturer, String licencePlate, int seatCount) {
+ this.manufacturer = manufacturer;
+ this.licensePlate = licencePlate;
+ this.seatCount = seatCount;
+ }
+
+ //getters and setters ...
+}</programlisting>
+ </example></para>
</section>
<section>
- <title>Field level annotations</title>
+ <title>Field-level constraints</title>
- <para>One way for expressing constraints is to annotate the fields of a
- class with constraint annotations. The following listing shows a simple
- example:</para>
+ <para>Constraints can also be expressed by annotating a field of a
+ class. The following listing shows a simple example:</para>
- <programlisting>package com.mycompany;
+ <example>
+ <title>Example for field level constraints</title>
+ <programlisting>package com.mycompany;
+
import javax.validation.constraints.NotNull;
public class Car {
@@ -74,24 +127,32 @@
private String manufacturer;
public Car(String manufacturer) {
-
this.manufacturer = manufacturer;
}
}</programlisting>
+ </example>
+
+ <para>When using field level constraints field access strategy is used
+ to access the value to be value. This means the bean validation provider
+ accesses the instance variable directly.</para>
</section>
<section>
- <title>Property level annotations</title>
+ <title>Property-level constraints</title>
<para>If your model class adheres to the <ulink type=""
url="http://java.sun.com/javase/technologies/desktop/javabeans/index.jsp">JavaBeans</ulink>
- standard (meaning basically, there are getter and setter methods for the
- properties of the class), it is also possible to annotate the properties
- of a bean class instead of its fields. Note that the property's getter
- method has to be annotated, not its setter method:</para>
+ standard, it is also possible to annotate the properties of a bean class
+ instead of its fields. <note>
+ <para>The property's getter method has to be annotated, not its
+ setter.</para>
+ </note></para>
- <programlisting>package com.mycompany;
+ <example>
+ <title>Example for property level constraints</title>
+ <programlisting>package com.mycompany;
+
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
@@ -100,8 +161,7 @@
private String manufacturer;
private boolean isRegistered;
-
-
+
public Car(String manufacturer, boolean isRegistered) {
super();
this.manufacturer = manufacturer;
@@ -126,20 +186,21 @@
this.isRegistered = isRegistered;
}
}</programlisting>
+ </example>
- <para>Generally it is considered a good practice to stick either with
- field <emphasis>or</emphasis> with property annotation within one model
- class for the sake of readability. It is not recommended to annotate a
- field <emphasis>and</emphasis> the accompanying getter method as this
- would cause the field to be validated twice.</para>
+ <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>
- <para>TODO: Make it explcit that where the difference lies between filed
- and property level annotations. Depending where I place the annotation
- the value to be validated gets accessed in different ways!</para>
+ <para>Generally it is recommended to stick either to field
+ <emphasis>or</emphasis> property annotation within one class. It is not
+ recommended to annotate a field <emphasis>and</emphasis> the
+ accompanying getter method as this would cause the field to be validated
+ twice.</para>
</section>
<section>
- <title>Annotated interfaces and super-classes</title>
+ <title>Constraint inheritance</title>
<para>When validating an object that implements an interface or extends
another class, all constraint annotations on the implemented interface
@@ -147,33 +208,11 @@
on the validated object itself. To make things clearer let's have a look
at the following example:</para>
- <programlisting>//class Car
-package com.mycompany;
+ <example>
+ <title>Example for constraint inheritance using RentalCar</title>
-import javax.validation.constraints.NotNull;
+ <programlisting>package com.mycompany;
-public class Car {
-
- private String manufacturer;
-
- public Car(String manufacturer) {
- this.manufacturer = manufacturer;
- }
-
- @NotNull
- public String getManufacturer() {
- return manufacturer;
- }
-
- public void setManufacturer(String manufacturer) {
- this.manufacturer = manufacturer;
- }
-
-}
-
-//class RentalCar
-package com.mycompany;
-
import javax.validation.constraints.NotNull;
public class RentalCar extends Car {
@@ -193,16 +232,17 @@
public void setRentalStation(String rentalStation) {
this.rentalStation = rentalStation;
}
-
}</programlisting>
+ </example>
- <para>Our well-known class <classname>Car</classname> is now extended by
- <classname>RentalCar</classname> with an additional property,
- <property>rentalStation</property>. If an instance of
- <classname>RentalCar</classname> is validated now, not only the
- <classname>@NotNull</classname> constraint at the
- <property>rentalStation</property> property would be validated, but also
- the constraint at <property>manufacturer</property> from the parent
+ <para>Our well-known class <classname>Car</classname> from <link
+ linkend="example-class-car">the getting started section</link> is now
+ extended by <classname>RentalCar</classname> with the additional
+ property <property>rentalStation</property>. If an instance of
+ <classname>RentalCar</classname> is validated, not only the
+ <classname>@NotNull</classname> constraint on
+ <property>rentalStation</property> would be validated, but also the
+ constraint at <property>manufacturer</property> from the parent
class.</para>
<para>The same would hold true, if <classname>Car</classname> was an
@@ -218,7 +258,7 @@
</section>
<section>
- <title>Validating object graphs</title>
+ <title>Object graphs</title>
<para>The Bean Validation API does not only allow to validate single
objects but also complete object graphs. To do so just annotate a field
@@ -228,7 +268,10 @@
<classname>@Valid</classname> will be validated as well (as will be
their children etc.). The following shows a simple example:</para>
- <programlisting>//class Person
+ <example>
+ <title>Class Person</title>
+
+ <programlisting>
package com.mycompany;
import javax.validation.constraints.NotNull;
@@ -250,12 +293,14 @@
public void setName(String name) {
this.name = name;
}
-
-}
+}</programlisting>
+ </example>
-//class car
-package com.mycompany;
+ <example>
+ <title>Adding a driver to the car</title>
+ <programlisting>package com.mycompany;
+
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
@@ -266,13 +311,12 @@
private Person driver;
public Car(Person driver) {
-
this.driver = driver;
}
//getters and setters ...
-
}</programlisting>
+ </example>
<para>If an instance of <classname>Car</classname> is validated, the
referenced <classname>Person</classname> object will be validated as
@@ -291,14 +335,13 @@
</listitem>
<listitem>
- <para>of type<classname> java.lang.Iterable</classname> (and
- therfore its direct or indirect derivations
- <classname>Collection</classname>, <classname>List</classname> and
- <classname>Set</classname>)</para>
+ <para>implement <classname>java.lang.Iterable</classname>
+ (especially <classname>Collection</classname>,
+ <classname>List</classname> and <classname>Set</classname>)</para>
</listitem>
<listitem>
- <para>of type <classname>java.util.Map</classname></para>
+ <para>implement <classname>java.util.Map</classname></para>
</listitem>
</itemizedlist>
@@ -306,8 +349,11 @@
cause each contained element to be validated, when the parent object is
validated.</para>
- <programlisting>package com.mycompany;
+ <example>
+ <title>Car with a list of passengers</title>
+ <programlisting>package com.mycompany;
+
import java.util.ArrayList;
import java.util.List;
@@ -322,40 +368,78 @@
@NotNull
@Valid
- private List&lt;Person&gt; passengers = new ArrayList&lt;Person&gt;();
+ private List<Person> passengers = new ArrayList<Person>();
- public Car(List&lt;Person&gt; passengers) {
-
+ public Car(List<Person> passengers) {
this.passengers = passengers;
}
//getters and setters ...
-
}</programlisting>
+ </example>
<para>If a <classname>Car</classname> instance is validated now, a
- <classname>ConstraintValidation</classname> will be raised, if any of
+ <classname>ConstraintValidation</classname> will be created, if any of
the <classname>Person</classname> objects contained in the
- <property>passengers</property> list has a <code>null</code>
- name.</para>
+ <property>passengers</property> list has a <code>null</code> name.<note>
+ <para><classname>null</classname> values are getting ignored when
+ validating object graphs. </para>
+ </note></para>
</section>
</section>
<section id="validator-usingvalidator-validate" revision="1">
- <title>Validating your model</title>
+ <title>Validating constraints</title>
<para>The <classname>Validator</classname> interface is the main entry
- point to the Bean Validation API. In the following we first will show how
- to obtain <classname>Validator</classname> instances using the
- bootstrapping mechanism that the API provides. Afterwards you'll learn how
- to use the different methods of the <classname>Validator</classname>
- interfaces followed by an overview of the information that
- <classname>ConstraintViolation</classname> instances offer.</para>
+ point to Bean Validation. In the following we first will show how to
+ obtain an <classname>Validator</classname> instance using the different
+ bootstrapping mechanisms. Afterwards we will learn how to use the
+ different methods of the <classname>Validator</classname>
+ interface.</para>
<section>
- <title>Obtaining Validator instances</title>
+ <title>Obtaining a Validator instance</title>
- <para>TODO: DefaultFactory, customization, note on thread safety</para>
+ <para>The first step towards validating a class instance is to get hold
+ of a <classname>Validator</classname> instance. The road to this
+ instance leads via the <classname>Validation</classname> class and a
+ <classname>ValidatorFactory</classname>. The by far easiest way is to
+ use the static
+ <methodname>Validation.buildDefaultValidatorFactory()</methodname>
+ method:<programlisting>ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+Validator validator = factory.getValidator();</programlisting>You can also use
+ the method <methodname>Validation.byDefaultProvider()</methodname> which
+ will allow you to configure several aspects of the created Validator
+ instance:<programlisting>Configuration<?> config = Validation.byDefaultProvider().configure();
+config.messageInterpolator(new MyMessageInterpolator())
+ .traversableResolver( new MyTraversableResolver())
+ .constraintValidatorFactory(new MyConstraintValidatorFactory());
+
+ValidatorFactory factory = config.buildValidatorFactory();
+Validator validator = factory.getValidator();
+</programlisting>We will learn more about
+ <classname>MessageInterpolator</classname> and
+ <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
+ one Bean Validation provider in your classpath. In this situation you
+ can make an explicit choice about which implementation to use. In the
+ case of Hibernate Validator the Validator creation looks
+ like:<programlisting>ValidatorConfiguration configuration = Validation.byProvider( HibernateValidator.class )
+config.messageInterpolator(new MyMessageInterpolator())
+ .traversableResolver( new MyTraversableResolver())
+ .constraintValidatorFactory(new MyConstraintValidatorFactory());
+
+ValidatorFactory factory = config.buildValidatorFactory();
+Validator validator = factory.getValidator();</programlisting></para>
+
+ <para><note>
+ <para>The generated <classname>Validator</classname> instance is
+ thread safe and can be cached.</para>
+ </note>Now that we have a <classname>Validator</classname> instance,
+ let's see how we can use it to validate class instances.</para>
</section>
<section>
@@ -449,8 +533,10 @@
</section>
<section id="validator-usingvalidator-validationgroups" revision="1">
- <title>Validation groups</title>
+ <title>Using groups</title>
+ <para></para>
+
<section revision="1">
<title>Group sequences</title>
@@ -458,7 +544,223 @@
</section>
</section>
- <section id="validator-usingvalidator-methodparameters" revision="1">
- <para />
+ <section id="validator-defineconstraints-builtin" revision="2">
+ <title>Built-in constraints</title>
+
+ <para>Hibernate Validator comes with some built-in constraints, which
+ covers most 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>
+
+ <table>
+ <title>Built-in constraints</title>
+
+ <tgroup cols="4">
+ <colspec align="center" />
+
+ <thead>
+ <row>
+ <entry>Annotation</entry>
+
+ <entry>Apply on</entry>
+
+ <entry>Runtime checking</entry>
+
+ <entry>Hibernate Metadata impact</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>@Length(min=, max=)</entry>
+
+ <entry>property (String)</entry>
+
+ <entry>check if the string length match the range</entry>
+
+ <entry>Column length will be set to max</entry>
+ </row>
+
+ <row>
+ <entry>@Max(value=)</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</entry>
+
+ <entry>check if the value is less than or equals to max</entry>
+
+ <entry>Add a check constraint on the column</entry>
+ </row>
+
+ <row>
+ <entry>@Min(value=)</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</entry>
+
+ <entry>check if the value is more than or equals to min</entry>
+
+ <entry>Add a check constraint on the column</entry>
+ </row>
+
+ <row>
+ <entry>@NotNull</entry>
+
+ <entry>property</entry>
+
+ <entry>check if the value is not null</entry>
+
+ <entry>Column(s) are not null</entry>
+ </row>
+
+ <row>
+ <entry>@NotEmpty</entry>
+
+ <entry>property</entry>
+
+ <entry>check if the string is not null nor empty. Check if the
+ connection is not null nor empty</entry>
+
+ <entry>Column(s) are not null (for String)</entry>
+ </row>
+
+ <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>
+ </row>
+
+ <row>
+ <entry>@Future</entry>
+
+ <entry>property (date or calendar)</entry>
+
+ <entry>check if the date is in the future</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Pattern(regex="regexp", flag=) or @Patterns(
+ {@Pattern(...)} )</entry>
+
+ <entry>property (string)</entry>
+
+ <entry>check if the property match the regular expression given a
+ match flag (see <classname>java.util.regex.Pattern </classname>
+ )</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Range(min=, max=)</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</entry>
+
+ <entry>check if the value is between min and max
+ (included)</entry>
+
+ <entry>Add a check constraint on the column</entry>
+ </row>
+
+ <row>
+ <entry>@Size(min=, max=)</entry>
+
+ <entry>property (array, collection, map)</entry>
+
+ <entry>check if the element size is between min and max
+ (included)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@AssertFalse</entry>
+
+ <entry>property</entry>
+
+ <entry>check that the method evaluates to false (useful for
+ constraints expressed in code rather than annotations)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@AssertTrue</entry>
+
+ <entry>property</entry>
+
+ <entry>check that the method evaluates to true (useful for
+ constraints expressed in code rather than annotations)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Valid</entry>
+
+ <entry>property (object)</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>none</entry>
+ </row>
+
+ <row>
+ <entry>@Email</entry>
+
+ <entry>property (String)</entry>
+
+ <entry>check whether the string is conform to the email address
+ specification</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@CreditCardNumber</entry>
+
+ <entry>property (String)</entry>
+
+ <entry>check whether the string is a well formated credit card
+ number (derivative of the Luhn algorithm)</entry>
+
+ <entry>none</entry>
+ </row>
+
+ <row>
+ <entry>@Digits</entry>
+
+ <entry>property (numeric or string representation of a
+ numeric)</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>define column precision and scale</entry>
+ </row>
+
+ <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>
+ </tgroup>
+ </table>
</section>
</chapter>
14 years, 7 months
Hibernate SVN: r17468 - in validator/trunk: hibernate-validator and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-02 09:24:17 -0400 (Wed, 02 Sep 2009)
New Revision: 17468
Modified:
validator/trunk/
validator/trunk/hibernate-validator-archetype/
validator/trunk/hibernate-validator-legacy/
validator/trunk/hibernate-validator-tck-runner/
validator/trunk/hibernate-validator/
Log:
Updated svn ignore patterns
Property changes on: validator/trunk
___________________________________________________________________
Name: svn:ignore
- target
build
*.iml
*.ipr
test_output
+ target
*.iml
*.ipr
.settings
.classpath
.project
.DS_Store
._*
Property changes on: validator/trunk/hibernate-validator
___________________________________________________________________
Name: svn:ignore
- target
build
*.iml
*.ipr
test_output
+ target
*.iml
*.ipr
.classpath
.project
.settings
._*
.DS_Store
Property changes on: validator/trunk/hibernate-validator-archetype
___________________________________________________________________
Name: svn:ignore
- target
build
*.iml
*.ipr
test_output
+ target
*.iml
*.ipr
.settings
.classpath
.project
Property changes on: validator/trunk/hibernate-validator-legacy
___________________________________________________________________
Name: svn:ignore
- target
build
*.iml
*.ipr
test_output
+ target
*.iml
*.ipr
.settings
.classpath
.project
._*
Property changes on: validator/trunk/hibernate-validator-tck-runner
___________________________________________________________________
Name: svn:ignore
- target
build
*.iml
*.ipr
test_output
+ target
*.iml
*.ipr
.settings
.classpath
.project
14 years, 7 months
Hibernate SVN: r17467 - validator/trunk/hibernate-validator/src/main/docbook/en-US.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-09-02 09:14:42 -0400 (Wed, 02 Sep 2009)
New Revision: 17467
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/master.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-02 13:14:22 UTC (rev 17466)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-09-02 13:14:42 UTC (rev 17467)
@@ -70,11 +70,11 @@
the same validation logic is implemented in each layer, proving time
consuming and error-prone. To avoid duplication of these validations in
each layer, developers often bundle validation logic directly into the
- domain model, cluttering domain classes with validation code that is, in
- fact, metadata about the class itself.</para>
+ domain model, cluttering domain classes with validation code which in fact
+ is metadata about the class itself.</para>
<para>JSR 303 - Bean Validation - defines a metadata model and API for
- JavaBean validation. The default metadata source is annotations, with the
+ entity validation. The default metadata source is annotations, with the
ability to override and extend the meta-data through the use of XML. The
API is not tied to a specific application tier or programming model. It is
specifically not tied to either the web tier or the persistence tier, and
@@ -98,9 +98,18 @@
<xi:include href="modules/customconstraints.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="modules/xmlconfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <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" />
+ <xi:include href="modules/xmlconfiguration.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+ <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>
14 years, 7 months