blob: f66e4b6189ade7ae49ea619e913004b8463226b2 [file] [view]
---
layout: default
title: RequiredStringValidator Annotation
parent:
title: Annotations
url: annotations.html
---
# RequiredStringValidator Annotation
This validator checks that a String field is not empty (i.e. non-null with a length > 0).
## Usage
The annotation must be applied at method level.
## Parameters
<p> <table class='confluenceTable' summary=''>
<tr>
<th class='confluenceTh'> Parameter </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Notes </th>
</tr>
<tr>
<td class='confluenceTd'>message</td>
<td class='confluenceTd'>yes</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>field error message</td>
</tr>
<tr>
<td class='confluenceTd'>key</td>
<td class='confluenceTd'>no</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>i18n key from language specific properties file.</td>
</tr>
<tr>
<td class='confluenceTd'>messageParams</td>
<td class='confluenceTd'>no</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>Additional params to be used to customize message - will be evaluated against the Value Stack</td>
</tr>
<tr>
<td class='confluenceTd'>fieldName</td>
<td class='confluenceTd'>no</td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'>shortCircuit</td>
<td class='confluenceTd'>no</td>
<td class='confluenceTd'>false</td>
<td class='confluenceTd'>If this validator should be used as shortCircuit.</td>
</tr>
<tr>
<td class='confluenceTd'>type</td>
<td class='confluenceTd'>yes</td>
<td class='confluenceTd'>ValidatorType.FIELD</td>
<td class='confluenceTd'>Enum value from ValidatorType. Either FIELD or SIMPLE can be used here.</td>
</tr>
<tr>
<td class='confluenceTd'> trim </td>
<td class='confluenceTd'> no </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Boolean property. Determines whether the String is trimmed before performing the length check. </td>
</tr>
</table>
</p>
## Examples
```java
@RequiredStringValidator(message = "Default message", key = "i18n.key", shortCircuit = true, trim = true)
```