import
java.util.Date;
import
javax.validation.constraints.Digits;
import
javax.validation.constraints.Email;
import
javax.validation.constraints.Future;
import
javax.validation.constraints.FutureOrPresent;
import
javax.validation.constraints.Max;
import
javax.validation.constraints.Min;
import
javax.validation.constraints.NegativeOrZero;
import
javax.validation.constraints.NotBlank;
import
javax.validation.constraints.NotEmpty;
import
javax.validation.constraints.NotNull;
import
javax.validation.constraints.Null;
import
javax.validation.constraints.PastOrPresent;
import
javax.validation.constraints.Pattern;
import
javax.validation.constraints.Pattern.Flag;
import
javax.validation.constraints.Positive;
import
javax.validation.constraints.Size;
import
org.hibernate.validator.constraints.CreditCardNumber;
import
org.hibernate.validator.constraints.Range;
import
org.hibernate.validator.constraints.URL;
public
class
GeekUser {
@NotNull
(message =
"Invalid Id. Please enter your Id"
)
private
Long geekUserId;
@Size
(max =
20
, min =
3
, message =
"Invalid Name, Size should be between 3 to 20"
)
@NotEmpty
(message =
"Please enter your name"
)
private
String geekUserName;
@Email
(message =
"Invalid EmailId.Please enter proper EmailId"
)
@NotEmpty
(message =
"Please enter your EmailId"
)
private
String geekUserEmailId;
@Digits
(integer =
3
, fraction =
3
, message =
"Invalid age, Maximum valid number for age is 3 digits"
)
private
int
geekAge;
@Max
(value =
5
, message =
"Invalid currentTimeOfWritingArticles, Maximum allowed is 5"
)
private
String currentTimeOfWritingArticles;
@Min
(value =
3
, message =
"Invalid allowedArticles, Minimum should be 3"
)
private
String allowedForArticleReviewing;
@NotBlank
(message =
"Invalid Proficiency 3, Proficiency 3 Should not be blank"
)
private
String proficiency3;
@Null
(message =
"Invalid Proficiency 4, Proficiency 4 should be null"
)
private
String proficiency4;
@Pattern
(regexp =
"YN"
, flags = {
Flag.CASE_INSENSITIVE }, message =
"Invalid Proficiency 5, Enter text not matches with the standards"
)
private
String proficiency5;
@Positive
(message =
"Invalid Rating, Value should be positive"
)
private
int
rating;
@NegativeOrZero
(message =
"Invalid value for blocklisted, Input Number should be negative or Zero"
)
private
int
blocklisted;
@Future
(message =
"Invalid date, It should be provided as future date"
)
private
Date futureDate;
@FutureOrPresent
(message =
"Invalid date, It should be as future or present date"
)
private
Date futureOrPresent;
@PastOrPresent
(message =
"Invalid date, It should be as Past or present date"
)
private
Date pastOrPresent;
@Range
(min =
1
, max =
3
, message =
"Invalid Range is given, Range should be within 1 to 3"
)
private
int
rangeExample;
@URL
(message =
"Invalid Url, Please provide a valid URL"
)
private
String urlExample;
@CreditCardNumber
(message =
"Invalid Creditcard, It should not contain invalid character"
)
private
String creditCardExample;
public
GeekUser(Long geekUserId, String geekUserName, String geekUserEmailId,
int
geekAge,
String currentTimeOfWritingArticles, String proficiency2,
String proficiency3, String proficiency4,
String proficiency5,
int
rating,
int
blocklisted,
Date futureDate, Date futureOrPresent,Date pastOrPresent,
int
rangeExample, String urlExample, String creditCardExample) {
super
();
this
.geekUserId = geekUserId;
this
.geekUserName = geekUserName;
this
.geekUserEmailId = geekUserEmailId;
this
.geekAge = geekAge;
this
.currentTimeOfWritingArticles = currentTimeOfWritingArticles;
this
.allowedForArticleReviewing = proficiency2;
this
.proficiency3 = proficiency3;
this
.proficiency4 = proficiency4;
this
.proficiency5 = proficiency5;
this
.rating = rating;
this
.blocklisted = blocklisted;
this
.futureDate = futureDate;
this
.futureOrPresent = futureOrPresent;
this
.pastOrPresent = pastOrPresent;
this
.rangeExample = rangeExample;
this
.urlExample = urlExample;
this
.creditCardExample = creditCardExample;
}
}