org.javalid.annotations.validation
Annotation Type NotEmpty


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

Checks if given getXXX method returns an empty String. Specify on getXXX method. Can be specified on method returning String or StringBuffer. Empty string is a String that is trimmed first (if set on the annotation), and then returns "" (thus length 0) or simply is NULL.

Validation error if the method checked returns an empty string.

Note: If the method returns NULL this is considered as empty too! You can use this annotation as a replacement for NotNull in cases such as Java Server Faces which often binds empty values to a variable (even if the user did not enter anything).

Since:
1.0
Version:
1.0
Author:
M.Reuvers

Optional Element Summary
 java.lang.String[] applyToGroups
          Specify for which groups this annotation must be applied.
 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.
 boolean trim
          Trim the String first, then check for non-empty.
 

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_"

trim

public abstract boolean trim
Trim the String first, then check for non-empty. Set to false if trim should not be done.

Defaults to true.

Default:
true

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.

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