@IsBoolean annotation

back to index

Action

Requires that the annotated element be a boolean value. If the value received is not directly a boolean, it attempts a conversion using either predefined or specified patterns.

Javadoc Ref :  Javadoc reference@IsBoolean

 Input Types 1
Object
 Output Types
boolean
   

1Automatic conversion will take place if the provided input does not match any of the input classes, as described in the conversions part of the manual.

Arguments

truePattern

Pattern representing the possible values that are interpreted as "true". Default is
(true)|(yes)|(1(\.0+)?)

falsePattern

Pattern representing the possible values that are interpreted as "false". Default is
(false)|(no)|(0(\\.0+)?)

notTrueMeansFalse

If set to true, only the "true" pattern is checked, and if it doesn't match, the value is assumed to be false automatically regardless of whether it matches the false pattern. Note that if set to true, this annotation will never cause a validation error.

notFalseMeansTrue

If set to true, only the "false" pattern is checked, and if it doesn't match, the value is assumed to be true automatically regardless of whether it matches the true pattern. Note that if set to true, this annotation will never cause a validation error.

padChar
Specifies which character to use when padding the value. Default is '0'
padLength
Specifies the length of the field into which to apply the padding. Default is 0
message

Literal message to use if validation fails.

errorCode
Error code to use if validation fails.
messageKey
Message key to use if validation fails.

 

Example

@IsBoolean(truePattern="(si)|(oui)", notTrueMeansFalse=true)
private boolean myBooleanField;