Author: epbernard
Date: 2009-06-10 14:41:22 -0400 (Wed, 10 Jun 2009)
New Revision: 16748
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertFalseValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertTrueValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendar.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForDate.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/LengthValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotNullValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NullValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendar.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForDate.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArray.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfBoolean.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfByte.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfChar.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfDouble.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfFloat.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfInt.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfLong.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfPrimitives.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfShort.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForCollection.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForMap.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/package.html
Removed:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertFalseValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertTrueValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForNumber.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForString.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java
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
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/package.html
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java
Log:
HV-166 Move constraints validator impl into org.hibernate.validation.constraints.impl
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertFalseValidator.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertFalseValidator.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertFalseValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,42 +0,0 @@
-// $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 javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.AssertFalse;
-
-/**
- * Validates that the value passed is false
- *
- * @author Alaa Nassef
- */
-public class AssertFalseValidator implements ConstraintValidator<AssertFalse,
Boolean> {
-
- public void initialize(AssertFalse constraintAnnotation) {
- }
-
- public boolean isValid(Boolean bool, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( bool == null ) {
- return true;
- }
- return !bool;
- }
-
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertTrueValidator.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertTrueValidator.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertTrueValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,42 +0,0 @@
-// $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 javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.AssertTrue;
-
-/**
- * Validates that the value passed is true
- *
- * @author Alaa Nassef
- */
-public class AssertTrueValidator implements ConstraintValidator<AssertTrue,
Boolean> {
-
- public void initialize(AssertTrue constraintAnnotation) {
- }
-
- public boolean isValid(Boolean bool, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( bool == null ) {
- return true;
- }
- return bool;
- }
-
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,72 +0,0 @@
-// $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.math.BigDecimal;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
-import javax.validation.constraints.Digits;
-
-/**
- * Validates that the <code>Number</code> being validates matches the
pattern
- * defined in the constraint.
- *
- * @author Alaa Nassef
- * @author Hardy Ferentschik
- */
-public class DigitsValidatorForNumber implements ConstraintValidator<Digits,
Number> {
-
- private int maxIntegerLength;
- private int maxFractionLength;
-
- public void initialize(Digits constraintAnnotation) {
- this.maxIntegerLength = constraintAnnotation.integer();
- this.maxFractionLength = constraintAnnotation.fraction();
- validateParameters();
- }
-
- public boolean isValid(Number num, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( num == null ) {
- return true;
- }
-
- BigDecimal bigNum;
- if ( num instanceof BigDecimal ) {
- bigNum = ( BigDecimal ) num;
- }
- else {
- bigNum = new BigDecimal( num.toString() );
- }
-
- int integerPartLength = bigNum.precision() - bigNum.scale();
- int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();
-
- return ( maxIntegerLength >= integerPartLength && maxFractionLength >=
fractionPartLength );
- }
-
- private void validateParameters() {
- if ( maxIntegerLength < 0 ) {
- throw new ValidationException( "The length of the interger part cannot be
negative." );
- }
- if ( maxFractionLength < 0 ) {
- throw new ValidationException( "The length of the fraction part cannot be
negative." );
- }
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,80 +0,0 @@
-// $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.math.BigDecimal;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
-import javax.validation.constraints.Digits;
-
-/**
- * Validates that the <code>String</code> being validated consists of
digits,
- * and matches the pattern defined in the constraint.
- *
- * @author Alaa Nassef
- * @author Hardy Ferentschik
- */
-public class DigitsValidatorForString implements ConstraintValidator<Digits,
String> {
-
- private int maxIntegerLength;
- private int maxFractionLength;
-
- public void initialize(Digits constraintAnnotation) {
- this.maxIntegerLength = constraintAnnotation.integer();
- this.maxFractionLength = constraintAnnotation.fraction();
- validateParameters();
- }
-
- public boolean isValid(String str, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( str == null ) {
- return true;
- }
-
- BigDecimal bigNum = getBigDecimalValue( str );
- if ( bigNum == null ) {
- return false;
- }
-
- int integerPartLength = bigNum.precision() - bigNum.scale();
- int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();
-
- return ( maxIntegerLength >= integerPartLength && maxFractionLength >=
fractionPartLength );
- }
-
- private BigDecimal getBigDecimalValue(String str) {
- BigDecimal bd;
- try {
- bd = new BigDecimal( str );
- }
- catch ( NumberFormatException nfe ) {
- return null;
- }
- return bd;
- }
-
- private void validateParameters() {
- if ( maxIntegerLength < 0 ) {
- throw new ValidationException( "The length of the interger part cannot be
negative." );
- }
- if ( maxFractionLength < 0 ) {
- throw new ValidationException( "The length of the fraction part cannot be
negative." );
- }
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,43 +0,0 @@
-// $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.util.Calendar;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Future;
-
-/**
- * Check that the <code>java.util.Calendar</code> passed to be validated is
in
- * the future.
- *
- * @author Alaa Nassef
- */
-public class FutureValidatorForCalendar implements ConstraintValidator<Future,
Calendar> {
-
- public void initialize(Future constraintAnnotation) {
- }
-
- public boolean isValid(Calendar cal, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( cal == null ) {
- return true;
- }
- return cal.after( Calendar.getInstance() );
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,43 +0,0 @@
-// $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.util.Date;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Future;
-
-/**
- * Check that the <code>java.util.Date</code> passed to be validated is in
the
- * future.
- *
- * @author Alaa Nassef
- */
-public class FutureValidatorForDate implements ConstraintValidator<Future, Date> {
-
- public void initialize(Future constraintAnnotation) {
- }
-
- public boolean isValid(Date date, ConstraintValidatorContext constraintValidatorContext)
{
- //null values are valid
- if ( date == null ) {
- return true;
- }
- return date.after( new Date() );
- }
-}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/Length.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -26,6 +26,8 @@
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import org.hibernate.validation.constraints.impl.LengthValidator;
+
/**
* Validate that the string is between min and max included
*
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,59 +0,0 @@
-// $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 javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
-
-/**
- * Check that a string's length is between min and max.
- *
- * @author Emmanuel Bernard
- * @author Gavin King
- */
-public class LengthValidator implements ConstraintValidator<Length, String> {
- private int min;
- private int max;
-
- public void initialize(Length parameters) {
- min = parameters.min();
- max = parameters.max();
- validateParameters();
- }
-
- public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
- if ( value == null ) {
- return true;
- }
- int length = value.length();
- return length >= min && length <= max;
- }
-
- 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
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForNumber.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForNumber.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForNumber.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,56 +0,0 @@
-// $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.math.BigDecimal;
-import java.math.BigInteger;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Max;
-
-/**
- * Check that the number being validated is less than or equal to the maximum
- * value specified.
- *
- * @author Alaa Nassef
- */
-public class MaxValidatorForNumber implements ConstraintValidator<Max, Number> {
-
- private long maxValue;
-
- public void initialize(Max maxValue) {
- this.maxValue = maxValue.value();
- }
-
- public boolean isValid(Number value, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( value == null ) {
- return true;
- }
- if ( value instanceof BigDecimal ) {
- return ( ( BigDecimal ) value ).compareTo( BigDecimal.valueOf( maxValue ) ) != 1;
- }
- else if ( value instanceof BigInteger ) {
- return ( ( BigInteger ) value ).compareTo( BigInteger.valueOf( maxValue ) ) != 1;
- }
- else {
- double doubleValue = value.doubleValue();
- return doubleValue <= maxValue;
- }
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForString.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForString.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,51 +0,0 @@
-// $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.math.BigDecimal;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Max;
-
-/**
- * Check that the String being validated represents a number, and has a value
- * less than or equal to the maximum value specified.
- *
- * @author Alaa Nassef
- */
-public class MaxValidatorForString implements ConstraintValidator<Max, String> {
-
- private long maxValue;
-
- public void initialize(Max maxValue) {
- this.maxValue = maxValue.value();
- }
-
- public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( value == null ) {
- return true;
- }
- try {
- return new BigDecimal( value ).compareTo( BigDecimal.valueOf( maxValue ) ) != 1;
- }
- catch ( NumberFormatException nfe ) {
- return false;
- }
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForNumber.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForNumber.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForNumber.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,57 +0,0 @@
-// $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.math.BigDecimal;
-import java.math.BigInteger;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Min;
-
-/**
- * Check that the number being validated is greater than or equal to the minimum
- * value specified.
- *
- * @author Alaa Nassef
- */
-public class MinValidatorForNumber implements ConstraintValidator<Min, Number> {
-
- private long minValue;
-
- public void initialize(Min minValue) {
- this.minValue = minValue.value();
- }
-
- public boolean isValid(Number value, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( value == null ) {
- return true;
- }
- if ( value instanceof BigDecimal ) {
- return ( ( BigDecimal ) value ).compareTo( BigDecimal.valueOf( minValue ) ) != -1;
- }
- else if ( value instanceof BigInteger ) {
- return ( ( BigInteger ) value ).compareTo( BigInteger.valueOf( minValue ) ) != -1;
- }
- else {
- double doubleValue = value.doubleValue();
- return doubleValue >= minValue;
- }
-
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForString.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForString.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,51 +0,0 @@
-// $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.math.BigDecimal;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Min;
-
-/**
- * Check that the String being validated represents a number, and has a value
- * more than or equal to the minimum value specified.
- *
- * @author Alaa Nassef
- */
-public class MinValidatorForString implements ConstraintValidator<Min, String> {
-
- private long minValue;
-
- public void initialize(Min minValue) {
- this.minValue = minValue.value();
- }
-
- public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( value == null ) {
- return true;
- }
- try {
- return new BigDecimal( ( String ) value ).compareTo( BigDecimal.valueOf( minValue ) )
!= -1;
- }
- catch ( NumberFormatException nfe ) {
- return false;
- }
- }
-}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmpty.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -25,6 +25,8 @@
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import org.hibernate.validation.constraints.impl.NotEmptyValidator;
+
/**
* @author Emmanuel Bernard
*/
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyValidator.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyValidator.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,39 +0,0 @@
-// $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 javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-/**
- * @author Hardy Ferentschik
- * @todo Extend to not only support strings, but also collections and maps. Needs to be
specified first though.
- */
-public class NotEmptyValidator implements ConstraintValidator<NotEmpty, String> {
-
- public void initialize(NotEmpty parameters) {
- }
-
- public boolean isValid(String object, ConstraintValidatorContext
constraintValidatorContext) {
- if ( object == null ) {
- return true;
- }
- int length = object.length();
- return length > 0;
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,37 +0,0 @@
-// $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 javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.NotNull;
-
-/**
- * Validate that the object is not <code>null</code>.
- *
- * @author Emmanuel Bernard
- */
-public class NotNullValidator implements ConstraintValidator<NotNull, Object> {
-
- public void initialize(NotNull parameters) {
- }
-
- public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
- return object != null;
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,38 +0,0 @@
-// $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 javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Null;
-
-/**
- * Validate that the object is <code>null</code>
- *
- * @author Alaa Nassef
- */
-public class NullValidator implements ConstraintValidator<Null, Object> {
-
- public void initialize(Null constraintAnnotation) {
- }
-
- public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
- return object == null;
- }
-
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,43 +0,0 @@
-// $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.util.Calendar;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Past;
-
-/**
- * Check that the <code>java.util.Calendar</code> passed to be validated is
in the
- * past.
- *
- * @author Alaa Nassef
- */
-public class PastValidatorForCalendar implements ConstraintValidator<Past,
Calendar> {
-
- public void initialize(Past constraintAnnotation) {
- }
-
- public boolean isValid(Calendar cal, ConstraintValidatorContext
constraintValidatorContext) {
- //null values are valid
- if ( cal == null ) {
- return true;
- }
- return cal.before( Calendar.getInstance() );
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,43 +0,0 @@
-// $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.util.Date;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.constraints.Past;
-
-/**
- * Check that the <code>java.util.Date</code> passed to be validated is in
the
- * past.
- *
- * @author Alaa Nassef
- */
-public class PastValidatorForDate implements ConstraintValidator<Past, Date> {
-
- public void initialize(Past constraintAnnotation) {
- }
-
- public boolean isValid(Date date, ConstraintValidatorContext constraintValidatorContext)
{
- //null values are valid
- if ( date == null ) {
- return true;
- }
- return date.before( new Date() );
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,56 +0,0 @@
-// $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.util.regex.Matcher;
-import java.util.regex.PatternSyntaxException;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
-import javax.validation.constraints.Pattern;
-
-/**
- * @author Hardy Ferentschik
- */
-public class PatternValidator implements ConstraintValidator<Pattern, String> {
-
- private java.util.regex.Pattern pattern;
-
- public void initialize(Pattern parameters) {
- Pattern.Flag flags[] = parameters.flags();
- int intFlag = 0;
- for ( Pattern.Flag flag : flags ) {
- intFlag = intFlag | flag.getValue();
- }
-
- try {
- pattern = java.util.regex.Pattern.compile( parameters.regexp(), intFlag );
- }
- catch ( PatternSyntaxException e ) {
- throw new ValidationException( "Invalid regular expression.", e );
- }
- }
-
- public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
- if ( value == null ) {
- return true;
- }
- Matcher m = pattern.matcher( value );
- return m.matches();
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,70 +0,0 @@
-// $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 SizeValidatorForArray implements ConstraintValidator<Size, Object[]>
{
- private int min;
- private int max;
-
- public void initialize(Size parameters) {
- min = parameters.min();
- max = parameters.max();
- validateParameters();
- }
-
- /**
- * 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(Object[] array, ConstraintValidatorContext
constraintValidatorContext) {
- if ( array == null ) {
- return true;
- }
- int length = Array.getLength( array );
- return length >= min && length <= max;
- }
-
- 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
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfBoolean.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfByte.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfChar.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfDouble.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfFloat.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfInt.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfLong.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfPrimitives.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,52 +0,0 @@
-// $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
Deleted:
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 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfShort.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,48 +0,0 @@
-// $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;
- }
-}
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,70 +0,0 @@
-// $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.util.Collection;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
-import javax.validation.constraints.Size;
-
-/**
- * Check that a string's length is between min and max.
- *
- * @author Hardy Ferentschik
- */
-public class SizeValidatorForCollection implements ConstraintValidator<Size,
Collection> {
- private int min;
- private int max;
-
- public void initialize(Size parameters) {
- min = parameters.min();
- max = parameters.max();
- validateParameters();
- }
-
- /**
- * Checks the number of entries in a map.
- *
- * @param collection The collection to validate.
- * @param constraintValidatorContext context in which the constraint is evaluated.
- *
- * @return Returns <code>true</code> if the collection is
<code>null</code> or the number of entries in
- * <code>collection</code> is between the specified
<code>min</code> and <code>max</code> values (inclusive),
- * <code>false</code> otherwise.
- */
- public boolean isValid(Collection collection, ConstraintValidatorContext
constraintValidatorContext) {
- if ( collection == null ) {
- return true;
- }
- int length = collection.size();
- return length >= min && length <= max;
- }
-
- 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
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,70 +0,0 @@
-// $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.util.Map;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
-import javax.validation.constraints.Size;
-
-/**
- * Check that a string's length is between min and max.
- *
- * @author Hardy Ferentschik
- */
-public class SizeValidatorForMap implements ConstraintValidator<Size, Map> {
- private int min;
- private int max;
-
- public void initialize(Size parameters) {
- min = parameters.min();
- max = parameters.max();
- validateParameters();
- }
-
- /**
- * Checks the number of entries in a map.
- *
- * @param map The map to validate.
- * @param constraintValidatorContext context in which the constraint is evaluated.
- *
- * @return Returns <code>true</code> if the map is
<code>null</code> or the number of entries in <code>map</code>
- * is between the specified <code>min</code> and
<code>max</code> values (inclusive),
- * <code>false</code> otherwise.
- */
- public boolean isValid(Map map, ConstraintValidatorContext constraintValidatorContext)
{
- if ( map == null ) {
- return true;
- }
- int size = map.size();
- return size >= min && size <= max;
- }
-
- 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
Deleted:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -1,70 +0,0 @@
-// $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 javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.ValidationException;
-import javax.validation.constraints.Size;
-
-/**
- * Check that a string's length is between min and max.
- *
- * @author Emmanuel Bernard
- * @author Gavin King
- * @author Hardy Ferentschik
- */
-public class SizeValidatorForString implements ConstraintValidator<Size, String> {
- private int min;
- private int max;
-
- public void initialize(Size parameters) {
- min = parameters.min();
- max = parameters.max();
- validateParameters();
- }
-
- /**
- * Checks the length of the specified string.
- *
- * @param s The string to validate.
- * @param constraintValidatorContext context in which the constraint is evaluated.
- *
- * @return Returns <code>true</code> if the string is
<code>null</code> or the length of <code>s</code> between the
specified
- * <code>min</code> and <code>max</code> values
(inclusive), <code>false</code> otherwise.
- */
- public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext)
{
- if ( s == null ) {
- return true;
- }
- int length = s.length();
- return length >= min && length <= max;
- }
-
- 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." );
- }
- }
-}
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertFalseValidator.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertFalseValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertFalseValidator.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertFalseValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,39 @@
+// $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.impl;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.AssertFalse;
+
+/**
+ * Validates that the value passed is false
+ *
+ * @author Alaa Nassef
+ */
+public class AssertFalseValidator implements ConstraintValidator<AssertFalse,
Boolean> {
+
+ public void initialize(AssertFalse constraintAnnotation) {
+ }
+
+ public boolean isValid(Boolean bool, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ return bool == null || !bool;
+ }
+
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertFalseValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertTrueValidator.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/AssertTrueValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertTrueValidator.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertTrueValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,39 @@
+// $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.impl;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.AssertTrue;
+
+/**
+ * Validates that the value passed is true
+ *
+ * @author Alaa Nassef
+ */
+public class AssertTrueValidator implements ConstraintValidator<AssertTrue,
Boolean> {
+
+ public void initialize(AssertTrue constraintAnnotation) {
+ }
+
+ public boolean isValid(Boolean bool, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ return bool == null || bool;
+ }
+
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/AssertTrueValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumber.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForNumber.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumber.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumber.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,72 @@
+// $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.impl;
+
+import java.math.BigDecimal;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Digits;
+
+/**
+ * Validates that the <code>Number</code> being validates matches the
pattern
+ * defined in the constraint.
+ *
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
+public class DigitsValidatorForNumber implements ConstraintValidator<Digits,
Number> {
+
+ private int maxIntegerLength;
+ private int maxFractionLength;
+
+ public void initialize(Digits constraintAnnotation) {
+ this.maxIntegerLength = constraintAnnotation.integer();
+ this.maxFractionLength = constraintAnnotation.fraction();
+ validateParameters();
+ }
+
+ public boolean isValid(Number num, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( num == null ) {
+ return true;
+ }
+
+ BigDecimal bigNum;
+ if ( num instanceof BigDecimal ) {
+ bigNum = ( BigDecimal ) num;
+ }
+ else {
+ bigNum = new BigDecimal( num.toString() );
+ }
+
+ int integerPartLength = bigNum.precision() - bigNum.scale();
+ int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();
+
+ return ( maxIntegerLength >= integerPartLength && maxFractionLength >=
fractionPartLength );
+ }
+
+ private void validateParameters() {
+ if ( maxIntegerLength < 0 ) {
+ throw new ValidationException( "The length of the interger part cannot be
negative." );
+ }
+ if ( maxFractionLength < 0 ) {
+ throw new ValidationException( "The length of the fraction part cannot be
negative." );
+ }
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForNumber.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForString.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/DigitsValidatorForString.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForString.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,80 @@
+// $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.impl;
+
+import java.math.BigDecimal;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Digits;
+
+/**
+ * Validates that the <code>String</code> being validated consists of
digits,
+ * and matches the pattern defined in the constraint.
+ *
+ * @author Alaa Nassef
+ * @author Hardy Ferentschik
+ */
+public class DigitsValidatorForString implements ConstraintValidator<Digits,
String> {
+
+ private int maxIntegerLength;
+ private int maxFractionLength;
+
+ public void initialize(Digits constraintAnnotation) {
+ this.maxIntegerLength = constraintAnnotation.integer();
+ this.maxFractionLength = constraintAnnotation.fraction();
+ validateParameters();
+ }
+
+ public boolean isValid(String str, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( str == null ) {
+ return true;
+ }
+
+ BigDecimal bigNum = getBigDecimalValue( str );
+ if ( bigNum == null ) {
+ return false;
+ }
+
+ int integerPartLength = bigNum.precision() - bigNum.scale();
+ int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();
+
+ return ( maxIntegerLength >= integerPartLength && maxFractionLength >=
fractionPartLength );
+ }
+
+ private BigDecimal getBigDecimalValue(String str) {
+ BigDecimal bd;
+ try {
+ bd = new BigDecimal( str );
+ }
+ catch ( NumberFormatException nfe ) {
+ return null;
+ }
+ return bd;
+ }
+
+ private void validateParameters() {
+ if ( maxIntegerLength < 0 ) {
+ throw new ValidationException( "The length of the interger part cannot be
negative." );
+ }
+ if ( maxFractionLength < 0 ) {
+ throw new ValidationException( "The length of the fraction part cannot be
negative." );
+ }
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/DigitsValidatorForString.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendar.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForCalendar.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendar.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendar.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,43 @@
+// $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.impl;
+
+import java.util.Calendar;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Future;
+
+/**
+ * Check that the <code>java.util.Calendar</code> passed to be validated is
in
+ * the future.
+ *
+ * @author Alaa Nassef
+ */
+public class FutureValidatorForCalendar implements ConstraintValidator<Future,
Calendar> {
+
+ public void initialize(Future constraintAnnotation) {
+ }
+
+ public boolean isValid(Calendar cal, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( cal == null ) {
+ return true;
+ }
+ return cal.after( Calendar.getInstance() );
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForCalendar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForDate.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/FutureValidatorForDate.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForDate.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForDate.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,43 @@
+// $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.impl;
+
+import java.util.Date;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Future;
+
+/**
+ * Check that the <code>java.util.Date</code> passed to be validated is in
the
+ * future.
+ *
+ * @author Alaa Nassef
+ */
+public class FutureValidatorForDate implements ConstraintValidator<Future, Date> {
+
+ public void initialize(Future constraintAnnotation) {
+ }
+
+ public boolean isValid(Date date, ConstraintValidatorContext constraintValidatorContext)
{
+ //null values are valid
+ if ( date == null ) {
+ return true;
+ }
+ return date.after( new Date() );
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/FutureValidatorForDate.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/LengthValidator.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/LengthValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/LengthValidator.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/LengthValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,61 @@
+// $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.impl;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+
+import org.hibernate.validation.constraints.Length;
+
+/**
+ * Check that a string's length is between min and max.
+ *
+ * @author Emmanuel Bernard
+ * @author Gavin King
+ */
+public class LengthValidator implements ConstraintValidator<Length, String> {
+ private int min;
+ private int max;
+
+ public void initialize(Length parameters) {
+ min = parameters.min();
+ max = parameters.max();
+ validateParameters();
+ }
+
+ public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
+ if ( value == null ) {
+ return true;
+ }
+ int length = value.length();
+ return length >= min && length <= max;
+ }
+
+ 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/impl/LengthValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumber.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForNumber.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumber.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumber.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,56 @@
+// $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.impl;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Max;
+
+/**
+ * Check that the number being validated is less than or equal to the maximum
+ * value specified.
+ *
+ * @author Alaa Nassef
+ */
+public class MaxValidatorForNumber implements ConstraintValidator<Max, Number> {
+
+ private long maxValue;
+
+ public void initialize(Max maxValue) {
+ this.maxValue = maxValue.value();
+ }
+
+ public boolean isValid(Number value, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( value == null ) {
+ return true;
+ }
+ if ( value instanceof BigDecimal ) {
+ return ( ( BigDecimal ) value ).compareTo( BigDecimal.valueOf( maxValue ) ) != 1;
+ }
+ else if ( value instanceof BigInteger ) {
+ return ( ( BigInteger ) value ).compareTo( BigInteger.valueOf( maxValue ) ) != 1;
+ }
+ else {
+ double doubleValue = value.doubleValue();
+ return doubleValue <= maxValue;
+ }
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForNumber.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForString.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MaxValidatorForString.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForString.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,51 @@
+// $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.impl;
+
+import java.math.BigDecimal;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Max;
+
+/**
+ * Check that the String being validated represents a number, and has a value
+ * less than or equal to the maximum value specified.
+ *
+ * @author Alaa Nassef
+ */
+public class MaxValidatorForString implements ConstraintValidator<Max, String> {
+
+ private long maxValue;
+
+ public void initialize(Max maxValue) {
+ this.maxValue = maxValue.value();
+ }
+
+ public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( value == null ) {
+ return true;
+ }
+ try {
+ return new BigDecimal( value ).compareTo( BigDecimal.valueOf( maxValue ) ) != 1;
+ }
+ catch ( NumberFormatException nfe ) {
+ return false;
+ }
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MaxValidatorForString.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForNumber.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForNumber.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForNumber.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForNumber.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,57 @@
+// $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.impl;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Min;
+
+/**
+ * Check that the number being validated is greater than or equal to the minimum
+ * value specified.
+ *
+ * @author Alaa Nassef
+ */
+public class MinValidatorForNumber implements ConstraintValidator<Min, Number> {
+
+ private long minValue;
+
+ public void initialize(Min minValue) {
+ this.minValue = minValue.value();
+ }
+
+ public boolean isValid(Number value, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( value == null ) {
+ return true;
+ }
+ if ( value instanceof BigDecimal ) {
+ return ( ( BigDecimal ) value ).compareTo( BigDecimal.valueOf( minValue ) ) != -1;
+ }
+ else if ( value instanceof BigInteger ) {
+ return ( ( BigInteger ) value ).compareTo( BigInteger.valueOf( minValue ) ) != -1;
+ }
+ else {
+ double doubleValue = value.doubleValue();
+ return doubleValue >= minValue;
+ }
+
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForNumber.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForString.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/MinValidatorForString.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForString.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,51 @@
+// $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.impl;
+
+import java.math.BigDecimal;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Min;
+
+/**
+ * Check that the String being validated represents a number, and has a value
+ * more than or equal to the minimum value specified.
+ *
+ * @author Alaa Nassef
+ */
+public class MinValidatorForString implements ConstraintValidator<Min, String> {
+
+ private long minValue;
+
+ public void initialize(Min minValue) {
+ this.minValue = minValue.value();
+ }
+
+ public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( value == null ) {
+ return true;
+ }
+ try {
+ return new BigDecimal( ( String ) value ).compareTo( BigDecimal.valueOf( minValue ) )
!= -1;
+ }
+ catch ( NumberFormatException nfe ) {
+ return false;
+ }
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/MinValidatorForString.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotEmptyValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,41 @@
+// $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.impl;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import org.hibernate.validation.constraints.NotEmpty;
+
+/**
+ * @author Hardy Ferentschik
+ * @todo Extend to not only support strings, but also collections and maps. Needs to be
specified first though.
+ */
+public class NotEmptyValidator implements ConstraintValidator<NotEmpty, String> {
+
+ public void initialize(NotEmpty parameters) {
+ }
+
+ public boolean isValid(String object, ConstraintValidatorContext
constraintValidatorContext) {
+ if ( object == null ) {
+ return true;
+ }
+ int length = object.length();
+ return length > 0;
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotEmptyValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotNullValidator.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NotNullValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotNullValidator.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotNullValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,37 @@
+// $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.impl;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Validate that the object is not <code>null</code>.
+ *
+ * @author Emmanuel Bernard
+ */
+public class NotNullValidator implements ConstraintValidator<NotNull, Object> {
+
+ public void initialize(NotNull parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
+ return object != null;
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NotNullValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NullValidator.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/NullValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NullValidator.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NullValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,38 @@
+// $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.impl;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Null;
+
+/**
+ * Validate that the object is <code>null</code>
+ *
+ * @author Alaa Nassef
+ */
+public class NullValidator implements ConstraintValidator<Null, Object> {
+
+ public void initialize(Null constraintAnnotation) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
+ return object == null;
+ }
+
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/NullValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendar.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForCalendar.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendar.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendar.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,43 @@
+// $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.impl;
+
+import java.util.Calendar;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Past;
+
+/**
+ * Check that the <code>java.util.Calendar</code> passed to be validated is
in the
+ * past.
+ *
+ * @author Alaa Nassef
+ */
+public class PastValidatorForCalendar implements ConstraintValidator<Past,
Calendar> {
+
+ public void initialize(Past constraintAnnotation) {
+ }
+
+ public boolean isValid(Calendar cal, ConstraintValidatorContext
constraintValidatorContext) {
+ //null values are valid
+ if ( cal == null ) {
+ return true;
+ }
+ return cal.before( Calendar.getInstance() );
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForCalendar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForDate.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PastValidatorForDate.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForDate.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForDate.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,43 @@
+// $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.impl;
+
+import java.util.Date;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Past;
+
+/**
+ * Check that the <code>java.util.Date</code> passed to be validated is in
the
+ * past.
+ *
+ * @author Alaa Nassef
+ */
+public class PastValidatorForDate implements ConstraintValidator<Past, Date> {
+
+ public void initialize(Past constraintAnnotation) {
+ }
+
+ public boolean isValid(Date date, ConstraintValidatorContext constraintValidatorContext)
{
+ //null values are valid
+ if ( date == null ) {
+ return true;
+ }
+ return date.before( new Date() );
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PastValidatorForDate.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/PatternValidator.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,56 @@
+// $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.impl;
+
+import java.util.regex.Matcher;
+import java.util.regex.PatternSyntaxException;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Pattern;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PatternValidator implements ConstraintValidator<Pattern, String> {
+
+ private java.util.regex.Pattern pattern;
+
+ public void initialize(Pattern parameters) {
+ Pattern.Flag flags[] = parameters.flags();
+ int intFlag = 0;
+ for ( Pattern.Flag flag : flags ) {
+ intFlag = intFlag | flag.getValue();
+ }
+
+ try {
+ pattern = java.util.regex.Pattern.compile( parameters.regexp(), intFlag );
+ }
+ catch ( PatternSyntaxException e ) {
+ throw new ValidationException( "Invalid regular expression.", e );
+ }
+ }
+
+ public boolean isValid(String value, ConstraintValidatorContext
constraintValidatorContext) {
+ if ( value == null ) {
+ return true;
+ }
+ Matcher m = pattern.matcher( value );
+ return m.matches();
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/PatternValidator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArray.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArray.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArray.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArray.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,70 @@
+// $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.impl;
+
+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 SizeValidatorForArray implements ConstraintValidator<Size, Object[]>
{
+ private int min;
+ private int max;
+
+ public void initialize(Size parameters) {
+ min = parameters.min();
+ max = parameters.max();
+ validateParameters();
+ }
+
+ /**
+ * 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(Object[] array, ConstraintValidatorContext
constraintValidatorContext) {
+ if ( array == null ) {
+ return true;
+ }
+ int length = Array.getLength( array );
+ return length >= min && length <= max;
+ }
+
+ 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/impl/SizeValidatorForArray.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfBoolean.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfBoolean.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfBoolean.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfBoolean.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @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/impl/SizeValidatorForArraysOfBoolean.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfByte.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfByte.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfByte.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfByte.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+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/impl/SizeValidatorForArraysOfByte.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfChar.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfChar.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfChar.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfChar.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+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/impl/SizeValidatorForArraysOfChar.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfDouble.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfDouble.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfDouble.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfDouble.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @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/impl/SizeValidatorForArraysOfDouble.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfFloat.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfFloat.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfFloat.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfFloat.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @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/impl/SizeValidatorForArraysOfFloat.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfInt.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfInt.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfInt.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfInt.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @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/impl/SizeValidatorForArraysOfInt.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfLong.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfLong.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfLong.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfLong.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @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/impl/SizeValidatorForArraysOfLong.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfPrimitives.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfPrimitives.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfPrimitives.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfPrimitives.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+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/impl/SizeValidatorForArraysOfPrimitives.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfShort.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForArraysOfShort.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfShort.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForArraysOfShort.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -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.impl;
+
+import java.lang.reflect.Array;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Size;
+
+/**
+ * @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/impl/SizeValidatorForArraysOfShort.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForCollection.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForCollection.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForCollection.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForCollection.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,70 @@
+// $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.impl;
+
+import java.util.Collection;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Size;
+
+/**
+ * Check that a string's length is between min and max.
+ *
+ * @author Hardy Ferentschik
+ */
+public class SizeValidatorForCollection implements ConstraintValidator<Size,
Collection> {
+ private int min;
+ private int max;
+
+ public void initialize(Size parameters) {
+ min = parameters.min();
+ max = parameters.max();
+ validateParameters();
+ }
+
+ /**
+ * Checks the number of entries in a map.
+ *
+ * @param collection The collection to validate.
+ * @param constraintValidatorContext context in which the constraint is evaluated.
+ *
+ * @return Returns <code>true</code> if the collection is
<code>null</code> or the number of entries in
+ * <code>collection</code> is between the specified
<code>min</code> and <code>max</code> values (inclusive),
+ * <code>false</code> otherwise.
+ */
+ public boolean isValid(Collection collection, ConstraintValidatorContext
constraintValidatorContext) {
+ if ( collection == null ) {
+ return true;
+ }
+ int length = collection.size();
+ return length >= min && length <= max;
+ }
+
+ 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/impl/SizeValidatorForCollection.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForMap.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForMap.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForMap.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForMap.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,70 @@
+// $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.impl;
+
+import java.util.Map;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Size;
+
+/**
+ * Check that a string's length is between min and max.
+ *
+ * @author Hardy Ferentschik
+ */
+public class SizeValidatorForMap implements ConstraintValidator<Size, Map> {
+ private int min;
+ private int max;
+
+ public void initialize(Size parameters) {
+ min = parameters.min();
+ max = parameters.max();
+ validateParameters();
+ }
+
+ /**
+ * Checks the number of entries in a map.
+ *
+ * @param map The map to validate.
+ * @param constraintValidatorContext context in which the constraint is evaluated.
+ *
+ * @return Returns <code>true</code> if the map is
<code>null</code> or the number of entries in <code>map</code>
+ * is between the specified <code>min</code> and
<code>max</code> values (inclusive),
+ * <code>false</code> otherwise.
+ */
+ public boolean isValid(Map map, ConstraintValidatorContext constraintValidatorContext)
{
+ if ( map == null ) {
+ return true;
+ }
+ int size = map.size();
+ return size >= min && size <= max;
+ }
+
+ 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/impl/SizeValidatorForMap.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForString.java
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/SizeValidatorForString.java)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForString.java
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForString.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,70 @@
+// $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.impl;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.ValidationException;
+import javax.validation.constraints.Size;
+
+/**
+ * Check that a string's length is between min and max.
+ *
+ * @author Emmanuel Bernard
+ * @author Gavin King
+ * @author Hardy Ferentschik
+ */
+public class SizeValidatorForString implements ConstraintValidator<Size, String> {
+ private int min;
+ private int max;
+
+ public void initialize(Size parameters) {
+ min = parameters.min();
+ max = parameters.max();
+ validateParameters();
+ }
+
+ /**
+ * Checks the length of the specified string.
+ *
+ * @param s The string to validate.
+ * @param constraintValidatorContext context in which the constraint is evaluated.
+ *
+ * @return Returns <code>true</code> if the string is
<code>null</code> or the length of <code>s</code> between the
specified
+ * <code>min</code> and <code>max</code> values
(inclusive), <code>false</code> otherwise.
+ */
+ public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext)
{
+ if ( s == null ) {
+ return true;
+ }
+ int length = s.length();
+ return length >= min && length <= max;
+ }
+
+ 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." );
+ }
+ }
+}
Property changes on:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/SizeValidatorForString.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/package.html
(from rev 16742,
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/package.html)
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/package.html
(rev 0)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/impl/package.html 2009-06-10
18:41:22 UTC (rev 16748)
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<!--
+
+ 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.
+
+-->
+</head>
+<body>
+This package contains the implementations of the builtin constraints as well as Hibernate
Validator specific
+constraint implementations.
+</body>
+</html>
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/package.html
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/package.html 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/constraints/package.html 2009-06-10
18:41:22 UTC (rev 16748)
@@ -21,7 +21,6 @@
-->
</head>
<body>
-This package contains the implementations of the builtin constraints as well as Hibernate
Validator specific
-constraints and their implementations.
+This package contains the Hibernate Validator specific constraints.
</body>
</html>
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-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -40,32 +40,32 @@
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
-import org.hibernate.validation.constraints.AssertFalseValidator;
-import org.hibernate.validation.constraints.AssertTrueValidator;
-import org.hibernate.validation.constraints.DigitsValidatorForNumber;
-import org.hibernate.validation.constraints.DigitsValidatorForString;
-import org.hibernate.validation.constraints.FutureValidatorForCalendar;
-import org.hibernate.validation.constraints.FutureValidatorForDate;
-import org.hibernate.validation.constraints.MaxValidatorForNumber;
-import org.hibernate.validation.constraints.MaxValidatorForString;
-import org.hibernate.validation.constraints.MinValidatorForNumber;
-import org.hibernate.validation.constraints.MinValidatorForString;
-import org.hibernate.validation.constraints.NotNullValidator;
-import org.hibernate.validation.constraints.NullValidator;
-import org.hibernate.validation.constraints.PastValidatorForCalendar;
-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;
+import org.hibernate.validation.constraints.impl.AssertFalseValidator;
+import org.hibernate.validation.constraints.impl.AssertTrueValidator;
+import org.hibernate.validation.constraints.impl.DigitsValidatorForNumber;
+import org.hibernate.validation.constraints.impl.DigitsValidatorForString;
+import org.hibernate.validation.constraints.impl.FutureValidatorForCalendar;
+import org.hibernate.validation.constraints.impl.FutureValidatorForDate;
+import org.hibernate.validation.constraints.impl.MaxValidatorForNumber;
+import org.hibernate.validation.constraints.impl.MaxValidatorForString;
+import org.hibernate.validation.constraints.impl.MinValidatorForNumber;
+import org.hibernate.validation.constraints.impl.MinValidatorForString;
+import org.hibernate.validation.constraints.impl.NotNullValidator;
+import org.hibernate.validation.constraints.impl.NullValidator;
+import org.hibernate.validation.constraints.impl.PastValidatorForCalendar;
+import org.hibernate.validation.constraints.impl.PastValidatorForDate;
+import org.hibernate.validation.constraints.impl.PatternValidator;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArray;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArraysOfBoolean;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArraysOfByte;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArraysOfChar;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArraysOfDouble;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArraysOfFloat;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArraysOfInt;
+import org.hibernate.validation.constraints.impl.SizeValidatorForArraysOfLong;
+import org.hibernate.validation.constraints.impl.SizeValidatorForCollection;
+import org.hibernate.validation.constraints.impl.SizeValidatorForMap;
+import org.hibernate.validation.constraints.impl.SizeValidatorForString;
import org.hibernate.validation.util.ReflectionHelper;
/**
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -32,7 +32,7 @@
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
-import org.hibernate.validation.constraints.NotNullValidator;
+import org.hibernate.validation.constraints.impl.NotNullValidator;
import org.hibernate.validation.engine.ConfigurationImpl;
import org.hibernate.validation.engine.ConstraintValidatorFactoryImpl;
import org.hibernate.validation.engine.HibernateValidatorConfiguration;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertFalseValidatorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -22,6 +22,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.AssertFalseValidator;
+
/**
* @author Alaa Nassef
*/
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/AssertTrueValidatorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -22,6 +22,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.AssertTrueValidator;
+
/**
* @author Alaa Nassef
*/
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -27,6 +27,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.DigitsValidatorForNumber;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -27,6 +27,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.DigitsValidatorForString;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForCalendarTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -24,6 +24,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.FutureValidatorForCalendar;
+
/**
* @author Alaa Nassef
* @author Hardy Ferentschik
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/FutureValidatorForDateTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -24,6 +24,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.FutureValidatorForDate;
+
public class FutureValidatorForDateTest {
private static FutureValidatorForDate constraint;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -25,6 +25,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.LengthValidator;
/**
* Tests the <code>LengthConstraint</code>.
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -28,6 +28,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.MaxValidatorForNumber;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -26,6 +26,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.MaxValidatorForString;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -28,6 +28,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.MinValidatorForNumber;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -26,6 +26,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.MinValidatorForString;
/**
* @author Alaa Nassef
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotEmptyValidatorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -22,6 +22,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.NotEmptyValidator;
+
/**
* @author Hardy Ferentschik
*/
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NotNullValidatorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -21,6 +21,8 @@
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.NotNullValidator;
+
/**
* @author Hardy Ferentschik
*/
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/NullValidatorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -22,6 +22,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.NullValidator;
+
/**
* @author Alaa Nassef
*/
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForCalendarTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -24,6 +24,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.PastValidatorForCalendar;
+
/**
* @author Alaa Nassef
* @author Hardy Ferentschik
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PastValidatorForDateTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -24,6 +24,8 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.hibernate.validation.constraints.impl.PastValidatorForDate;
+
public class PastValidatorForDateTest {
private static PastValidatorForDate constraint;
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -26,6 +26,7 @@
import org.hibernate.validation.util.annotationfactory.AnnotationDescriptor;
import org.hibernate.validation.util.annotationfactory.AnnotationFactory;
+import org.hibernate.validation.constraints.impl.PatternValidator;
/**
* @author Hardy Ferentschik
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java 2009-06-10
18:38:26 UTC (rev 16747)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/ConstraintDescriptorTest.java 2009-06-10
18:41:22 UTC (rev 16748)
@@ -32,7 +32,7 @@
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
-import org.hibernate.validation.constraints.NotNullValidator;
+import org.hibernate.validation.constraints.impl.NotNullValidator;
import org.hibernate.validation.engine.Order;
import org.hibernate.validation.engine.constraintcomposition.GermanAddress;
import org.hibernate.validation.util.LoggerFactory;