ValidateProperty task

Validates the value of a property on whether it is set, whether the value is empty, or against a list of possible values, and fails the Ant build when validation fails.

Parameters

Attribute Description Required
property The name of the property to validate. Yes
nonEmpty Whether the property should be non-empty. No; Defaults to false
trim Whether to trim the property before validation. No; Defaults to false

Nested elements

ValidValue

Specifies a valid value of the property.

The following table describes the nested elements.

Attribute Description Required
value The valid string value of the property. Exactly one of the two
regex The regular expression to match the property for validity.

Examples

The following example validates that the source.dir property is set.
<validateProperty property="source.dir" />
The following example validates that the source.dir property is set and is non-empty without leading and trailing spaces.
<validateProperty property="source.dir" nonEmpty="true" trim="true" />