|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.javalid.core.validator.NotEmptyValidatorImpl
public class NotEmptyValidatorImpl
This class is responsible for validating the NotEmpty annotation. Checks if given value is not empty (for String / StringBuffer values only). A null value is seen as empty too. Can be a replacement for NotNull if you want notempty to be checked too. The handling by the framework is similar, NotNull aborts processing of remaining annotations (as its useless if something is null), the same goes for this annotation if it is violated.
Can be applied to methods returning: java.lang.String or java.lang.StringBuffer. On error adds a ValidationMessage of: MessageCodes.MSG_NOT_EMPTY_ERROR for empty strings, in case of a NULL object sets: MessageCodes.MSG_NOT_NULL_ERROR
ValidationMessage's value property contains {currentValue}
Changes for 1.1:
| Constructor Summary | |
|---|---|
NotEmptyValidatorImpl()
|
|
| Method Summary | |
|---|---|
java.util.List<ValidationMessage> |
validate(NotEmpty annotation,
java.lang.Object value,
java.lang.String path,
JvConfigurationWrapper config)
This method is responsible for validating given value for the annotation this class is responsible for. |
boolean |
validationMustBeAppliedToGroup(NotEmpty annotation,
java.lang.String groupName,
JvGroup jvGroup,
JvConfigurationWrapper config)
Implementors must return true if given groupName must indeed apply validation on its method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NotEmptyValidatorImpl()
| Method Detail |
|---|
public java.util.List<ValidationMessage> validate(NotEmpty annotation,
java.lang.Object value,
java.lang.String path,
JvConfigurationWrapper config)
JavalidValidator
validate in interface JavalidValidator<NotEmpty>annotation - The annotation it is aboutvalue - The value to validatepath - The framework gives the full path for this value you are validating, thus
you can use it directly in the ValidationMessage as path.config - Wrapper containing public configuration info (such as reflectionsupport, beanlookup, can be used if needed)
public boolean validationMustBeAppliedToGroup(NotEmpty annotation,
java.lang.String groupName,
JvGroup jvGroup,
JvConfigurationWrapper config)
JavalidValidatorExample: JvGroup (create,edit), groupName=create and the annotation in question has as groups {JvGroup.GROUP_APPLY_ALL}. This means the annotation supports ANY group that is defined for JvGroup, in this example JvGroup defines create and an edit group. As the annotation defines JV_GROUP_ALL and the requested group=create, it does exist in JvGroup and the annotation supports any group, thus true must be returend.
Another example: JvGroup(create,edit), groupName=edit, annotation={create}. Group requested is edit, this exists for JvGroup, yet the annotation defines only to validate for create. Thus false must be returned.
Last example: JvGroup(create,edit), groupName='delete', annotation={create,edit,delete}. The groupName requested (delete) does not exist in JvGroup and must be skipped always whatever the annotation says (delete group in annotation is useless as it is not part of the JvGroup).
validationMustBeAppliedToGroup in interface JavalidValidator<NotEmpty>annotation - The annotation it is aboutgroupName - The groupName, the groupName we wish to know about whether it is allowed
or not (this is the group currently being validated).jvGroup - the group to check in if requested groupName is indeed ok to be validated (it must exist in that array of groups)config - Wrapper containing public configuration info (such as reflectionsupport, beanlookup, can be used if needed)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||