org.javalid.annotations.validation
Annotation Type DateEqual


@Target(value={METHOD,FIELD})
@Retention(value=RUNTIME)
@Documented
public @interface DateEqual

This annotation can be used to check if annotated field/method's date is equal to another date (property, which must be set using an expression). For instance

@DateEqual(otherDate="${parent.anotherDate}")

Where parent refers to the object that declares annotated field/method, thus anotherDate is a field or method of that object.

Property Supports normal value Supports expression value Note
applyToGroups Yes Yes You can return a String[] array as expression or even a single String (which is then handled as a single group), the elements inside the array may be expressions too (or only the elements of the array can be an expression)
customCode Yes Yes Normal is a property name (from a properties file), an expression must resolve to a String that is a property again
globalMessage Yes No
otherDate No Yes
convertType Yes No
pattern Yes Yes An expression must resolve to a date pattern (see pattern documentation)

Note: If you need to compare dates through String values (as input), please check DateCheck.

Since:
1.2
Version:
1.0
Author:
M.Reuvers
See Also:
DateCheck, DateBefore, DateAfter, DateNotEqual

Required Element Summary
 java.lang.String otherDate
          Expression which must point to another java.util.Date (or subclass) method/field.
 
Optional Element Summary
 java.lang.String[] applyToGroups
          Specify for which groups this annotation must be applied.
 int convertType
          The dates are converted to this type, meaning that the actual comparison is done this way (e.g TYPE_CONVERT_DATE means that the dates are compared on their date's only, time is not included).
 java.lang.String customCode
          Optional custom code (property from a properties file).
 boolean globalMessage
          If this annotation's message must be added as global message instead of real validation path.
 java.lang.String pattern
          The pattern used when converting dates to a representation in the validion error messages.
 

Element Detail

otherDate

public abstract java.lang.String otherDate
Expression which must point to another java.util.Date (or subclass) method/field. So for instance to refer to a property on the same class you would use: before="${parent.anotherDate}"

convertType

public abstract int convertType
The dates are converted to this type, meaning that the actual comparison is done this way (e.g TYPE_CONVERT_DATE means that the dates are compared on their date's only, time is not included). Defaults to TYPE_CONVERT_DATE. Use one of the TYPE_CONVERT_ constants of this class.

Default:
1

pattern

public abstract java.lang.String pattern
The pattern used when converting dates to a representation in the validion error messages. (uses the formats supported by java.util.SimpleDateFormatter).

This is used only for representational issues. Can be specified in normal text or as an expression (the latter can be used so you can assure the appropriate pattern for a locale is used).

Default:
"yyyy-MM-dd"

applyToGroups

public abstract java.lang.String[] applyToGroups
Specify for which groups this annotation must be applied. By default if you annotate without this variable, the annotation is applied for any group on that method (which is what you usually want). However by specifying the exact groups you can turn on/off a validation on a method depending on the group you validate.

Defaults to JvGroup.GROUP_APPLY_ALL

Default:
"_all_"

customCode

public abstract java.lang.String customCode
Optional custom code (property from a properties file). If set, this one is used instead of the default one specified in MessageCodes for annotated method/field.

This way you can override the default message if needed.

Default:
""

globalMessage

public abstract boolean globalMessage
If this annotation's message must be added as global message instead of real validation path. Defaults to false (thus will be added with validation path if invalid).

Default:
false