Annotation Type MustBeEqualIfOtherHasValue
@Documented
@Constraint(validatedBy=MustBeEqualIfOtherHasValueValidator.class)
@Target({TYPE,ANNOTATION_TYPE})
@Retention(RUNTIME)
public @interface MustBeEqualIfOtherHasValue
The annotated bean must contain at least four properties:
Supported types are beans,
- a field to compare (option
field1) - another field to compared (option
field2) - a field which entry is compared against a value (option
fieldCompareandvalueCompare) - add the error to field1 (option
addErrorToField1, default true) - add the error to field2 (option
addErrorToField2, default true)
field1 must be equal to the entry of field2 when the entry
of fieldCompare has the value valueCompare, can be used e.g. for
password and password repeat fields.Supported types are beans,
null elements are considered valid.- Author:
- Manfred Tremmel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceDefines severalMustBeEqualIfOtherHasValueannotations on the same element. -
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionfield1 name to compare.field2 name to compare.field name to compare.String[]value the compare field must have to check. -
Optional Element Summary
Optional Elements
-
Element Details
-
field1
String field1field1 name to compare.- Returns:
- field/path contains value to compare
-
field2
String field2field2 name to compare.- Returns:
- field/path contains value to compare
-
fieldCompare
String fieldComparefield name to compare.- Returns:
- field/path contains value to compare
-
valueCompare
String[] valueComparevalue the compare field must have to check.- Returns:
- value to compare
-
-
-
message
String messagelocalized message.- Returns:
- localized validation message
- Default:
- "{de.knightsoftnet.validators.shared.MustBeEqual.message}"
-
groups
Class<?>[] groupsgroups to use.- Returns:
- array of validation groups
- Default:
- {}
-
addErrorToField1
boolean addErrorToField1add error to field1 (default true).- Returns:
- true if error should be added to field1
- Default:
- true
-
addErrorToField2
boolean addErrorToField2add error to field2 (default true).- Returns:
- true if error should be added to field2
- Default:
- true
-
payload
Class<? extends jakarta.validation.Payload>[] payloadpayload whatever.- Returns:
- payload class
- Default:
- {}
-