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:
    • a field to compare (option field1)
    • another field to compared (option field2)
    • a field which entry is compared against a value (option fieldCompare and valueCompare)
    • add the error to field1 (option addErrorToField1, default true)
    • add the error to field2 (option addErrorToField2, default true)
    the entry of 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
    • Element Detail

      • field1

        String field1
        field1 name to compare.
        Returns:
        field/path contains value to compare
      • field2

        String field2
        field2 name to compare.
        Returns:
        field/path contains value to compare
      • fieldCompare

        String fieldCompare
        field name to compare.
        Returns:
        field/path contains value to compare
      • valueCompare

        String[] valueCompare
        value the compare field must have to check.
        Returns:
        value to compare
      • message

        String message
        localized message.
        Returns:
        localized validation message
        Default:
        "{de.knightsoftnet.validators.shared.MustBeEqual.message}"
      • groups

        Class<?>[] groups
        groups to use.
        Returns:
        array of validation groups
        Default:
        {}
      • addErrorToField1

        boolean addErrorToField1
        add error to field1 (default true).
        Returns:
        true if error should be added to field1
        Default:
        true
      • addErrorToField2

        boolean addErrorToField2
        add error to field2 (default true).
        Returns:
        true if error should be added to field2
        Default:
        true
      • payload

        Class<? extends javax.validation.Payload>[] payload
        payload whatever.
        Returns:
        payload class
        Default:
        {}