[hibernate-commits] Hibernate SVN: r16723 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation: engine and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Jun 9 10:27:01 EDT 2009


Author: hardy.ferentschik
Date: 2009-06-09 10:27:01 -0400 (Tue, 09 Jun 2009)
New Revision: 16723

Added:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfBoolean.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfByte.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfChar.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfDouble.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfFloat.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfInt.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfLong.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfPrimitives.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfShort.java
Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java
Log:
Added @Size validators for primitive array types.

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfBoolean.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfBoolean.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfBoolean.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.constraints.Size;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+*/
+public class SizeValidatorForArraysOfBoolean extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, boolean[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(boolean[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfBoolean.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfByte.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfByte.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfByte.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SizeValidatorForArraysOfByte extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, byte[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(byte[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfByte.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfChar.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfChar.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfChar.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SizeValidatorForArraysOfChar extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, char[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(char[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfChar.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfDouble.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfDouble.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfDouble.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.constraints.Size;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+*/
+public class SizeValidatorForArraysOfDouble extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, double[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(double[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfDouble.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfFloat.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfFloat.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfFloat.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.constraints.Size;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+*/
+public class SizeValidatorForArraysOfFloat extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, float[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(float[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfFloat.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfInt.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfInt.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfInt.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.constraints.Size;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+*/
+public class SizeValidatorForArraysOfInt extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, int[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(int[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfInt.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfLong.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfLong.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfLong.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.constraints.Size;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+*/
+public class SizeValidatorForArraysOfLong extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, long[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(long[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfLong.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfPrimitives.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfPrimitives.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfPrimitives.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,52 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Size;
+
+/**
+ * Check that the length of an array is betweeb <i>min</i> and <i>max</i>
+ *
+ * @author Hardy Ferentschik
+ */
+public class SizeValidatorForArraysOfPrimitives {
+	protected int min;
+	protected int max;
+
+	public void initialize(Size parameters) {
+		min = parameters.min();
+		max = parameters.max();
+		validateParameters();
+	}
+
+	private void validateParameters() {
+		if ( min < 0 ) {
+			throw new ValidationException( "The min parameter cannot be negative." );
+		}
+		if ( max < 0 ) {
+			throw new ValidationException( "The max paramter cannot be negative." );
+		}
+		if ( max < min ) {
+			throw new ValidationException( "The length cannot be negative." );
+		}
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfPrimitives.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfShort.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfShort.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfShort.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -0,0 +1,48 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.constraints;
+
+import java.lang.reflect.Array;
+import javax.validation.constraints.Size;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+*/
+public class SizeValidatorForArraysOfShort extends SizeValidatorForArraysOfPrimitives
+		implements ConstraintValidator<Size, short[]> {
+
+	/**
+	 * Checks the number of entries in an array.
+	 *
+	 * @param array The array to validate.
+	 * @param constraintValidatorContext context in which the constraint is evaluated.
+	 *
+	 * @return Returns <code>true</code> if the array is <code>null</code> or the number of entries in
+	 *         <code>array</code> is between the specified <code>min</code> and <code>max</code> values (inclusive),
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean isValid(short[] array, ConstraintValidatorContext constraintValidatorContext) {
+		if ( array == null ) {
+			return true;
+		}
+		int length = Array.getLength( array );
+		return length >= min && length <= max;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfShort.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java	2009-06-09 14:26:06 UTC (rev 16722)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java	2009-06-09 14:27:01 UTC (rev 16723)
@@ -56,6 +56,13 @@
 import org.hibernate.validation.constraints.PastValidatorForDate;
 import org.hibernate.validation.constraints.PatternValidator;
 import org.hibernate.validation.constraints.SizeValidatorForArray;
+import org.hibernate.validation.constraints.SizeValidatorForArraysOfBoolean;
+import org.hibernate.validation.constraints.SizeValidatorForArraysOfByte;
+import org.hibernate.validation.constraints.SizeValidatorForArraysOfChar;
+import org.hibernate.validation.constraints.SizeValidatorForArraysOfDouble;
+import org.hibernate.validation.constraints.SizeValidatorForArraysOfFloat;
+import org.hibernate.validation.constraints.SizeValidatorForArraysOfInt;
+import org.hibernate.validation.constraints.SizeValidatorForArraysOfLong;
 import org.hibernate.validation.constraints.SizeValidatorForCollection;
 import org.hibernate.validation.constraints.SizeValidatorForMap;
 import org.hibernate.validation.constraints.SizeValidatorForString;
@@ -124,6 +131,13 @@
 		constraintList.add( SizeValidatorForCollection.class );
 		constraintList.add( SizeValidatorForArray.class );
 		constraintList.add( SizeValidatorForMap.class );
+		constraintList.add( SizeValidatorForArraysOfBoolean.class );
+		constraintList.add( SizeValidatorForArraysOfByte.class );
+		constraintList.add( SizeValidatorForArraysOfChar.class );
+		constraintList.add( SizeValidatorForArraysOfDouble.class );
+		constraintList.add( SizeValidatorForArraysOfFloat.class );
+		constraintList.add( SizeValidatorForArraysOfInt.class );
+		constraintList.add( SizeValidatorForArraysOfLong.class );
 		builtinConstraints.put( Size.class, constraintList );
 
 		constraintList = new ArrayList<Class<? extends ConstraintValidator<?, ?>>>();




More information about the hibernate-commits mailing list