Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Bean Validation: @AssertFalse: Validate falsity of the element

If you annotate any Element with @AssertFalse annotation, then the annotated element must be false.

Supported Types
a.   boolean
b.   Boolean

Where can I apply this annotation?
a.   METHOD,
b.   FIELD,
c.    ANNOTATION_TYPE,
d.   CONSTRUCTOR,
e.   PARAMETER,
f.     TYPE_USE

Employee.java
package com.sample.model;

import javax.validation.constraints.AssertFalse;

public class Employee {

private int id;

@AssertFalse
private boolean isExperienced;

public Employee(int id, boolean isExperienced) {
this.id = id;
this.isExperienced = isExperienced;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public boolean isExperienced() {
return isExperienced;
}

public void setExperienced(boolean isExperienced) {
this.isExperienced = isExperienced;
}

}



This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Bean Validation: @AssertFalse: Validate falsity of the element

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×