To validate components with the Force.com Migration Tool, set the checkOnly option to true in the deploy target. See Deploying Changes to a Salesforce Organization in the Force.com Migration Tool Guide.
checkOnly : Defaults to false. Set to true to check the validity of the deployed files without making any changes in the organization. This will not deploy any components or change the organization in any way.
To add conditional command in ant script you can set dependency using "Depends" attribute.
<target name="test.if.tomcat.is.running">
<condition property="tomcat.running" value="true" else="false">
<socket server="${tomcat.host}" port="${tomcat.port}"/>
</condition>
</target>
<target name="my.target.running"
if="${tomcat.running}"
depends="test.if.tomcat.is.running">
...
</target>
<target name="my.target.ifnotrunning"
unless="${tomcat.running}"
depends="test.if.tomcat.is.running">
.....
</target>