spring validation annotation for compulsory and non-compulsory fields -


     @notempty private string cname; public string getcname() {     return cname; } public void setcname(string cname) {     this.cname = cname; }  private string cdescription; public string getcdescription() {     return cdescription; } public setcdescription(string cdescription) {     if(cdescription.length()>0){     this.cdescription = cdescription;} 

in above code,cname compulsory field , cdescription non-compulsory field has validated.cname working fine. want know how can validate cdescription w/o making compulsory

as per requirement can use different annotations of javax.validation http://docs.oracle.com/javaee/6/api/javax/validation/constraints/package-summary.html hibernate validation you.@notblank , @notnull , @notempty various types of annotation available in hibernate-validator jar.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -