-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Added OneOf annotation and constraint details in BuiltinConstraint…
…, ConstraintHelper, TypeNames. 2. Added OneOfDef and its unit test. 3. Added documentation in ch02.asciidoc. 4. Updated OneOf constraints to accept different array data types like int, long, float and double. 5. Updated OneOfValidator to map to Object instead of CharSequence so that it can be used on fields with Integer, Long, Float, Double and String types. 6. Added detailed unit tests for OneOf in OneOfValidatorTest. 7. Added validation messages for OneOf message code or key in ValidationMessages_[LOCALE].properties files.
- Loading branch information
Yusuf Alamu Musa
committed
Jan 17, 2025
1 parent
b29d458
commit 798f3a0
Showing
37 changed files
with
709 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
engine/src/main/java/org/hibernate/validator/cfg/defs/OneOfDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.validator.cfg.defs; | ||
|
||
import org.hibernate.validator.cfg.ConstraintDef; | ||
import org.hibernate.validator.constraints.OneOf; | ||
|
||
public class OneOfDef extends ConstraintDef<OneOfDef, OneOf> { | ||
|
||
public OneOfDef() { | ||
super( OneOf.class ); | ||
} | ||
|
||
public OneOfDef enumClass(Class<? extends Enum<?>> enumClass) { | ||
addParameter( "enumClass", enumClass ); | ||
return this; | ||
} | ||
|
||
public OneOfDef allowedIntegers(int[] allowedIntegers) { | ||
addParameter( "allowedIntegers", allowedIntegers ); | ||
return this; | ||
} | ||
|
||
public OneOfDef allowedLongs(long[] allowedLongs) { | ||
addParameter( "allowedLongs", allowedLongs ); | ||
return this; | ||
} | ||
|
||
public OneOfDef allowedFloats(float[] allowedFloats) { | ||
addParameter( "allowedFloats", allowedFloats ); | ||
return this; | ||
} | ||
|
||
public OneOfDef allowedDoubles(double[] allowedDoubles) { | ||
addParameter( "allowedDoubles", allowedDoubles ); | ||
return this; | ||
} | ||
|
||
public OneOfDef allowedValues(String[] allowedValues) { | ||
addParameter( "allowedValues", allowedValues ); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.