public final class ValidationMessages extends MessageFactory
MessageFactory
that provides the feedback messages
for the Validator
s that are provided out of the box.
By default, it uses a default bundle with the default messages
in english language, but it is also possible to provide a custom
bundle and Locale
DEFAULT_RELOAD_CONTROL, logger, reloadControl
Constructor and Description |
---|
ValidationMessages()
Creates an instance which uses the default
english language bundle which ships with
the module
|
ValidationMessages(String bundlePath,
String locale)
Creates an instance which points to the given
bundlePath and locale |
Modifier and Type | Method and Description |
---|---|
Message |
arrayIsEmpty()
Generates a
Message for an array which was expected
to be not empty but was |
Message |
arrayIsNotEmpty()
Generates a
Message for an array
which was expected to be empty but wasn't |
Message |
collectionIsEmpty()
Generates a
Message for a value that was
expected to be not empty but was |
Message |
collectionIsNotEmpty()
Generates a
Message for a Collection
which was expected to be empty but wasn't |
Message |
failedBooleanValidation(boolean value,
boolean expected)
Generates a
Message for a boolean validation that failed |
protected ResourceBundle |
getBundle(String bundlePath) |
Message |
greaterThan(Object value,
Object boundary)
Returns a message for a
value that was
expected to be greater than boundary but isn't |
Message |
greaterThanMaxSize(Object value,
int maxSize,
int actualSize)
Generates a
Message for a value that was expected to have
a maximum size but didn't |
Message |
invalidEmail(String email)
Generates a
Message for an email validation
that failed |
Message |
invalidIp(String ip)
Generates a
Message for an ip address
validation that failed |
Message |
invalidNumberType(Object value,
String numberType)
Generates a
Message for a number type validation that failed |
Message |
invalidTime(String time,
String locale,
String pattern)
|
Message |
invalidUrl(String url)
Generates a
Message for a url that is not valid |
Message |
lowerThan(Object value,
Object boundary)
Returns a message for a
value that was
expected to be lower than boundary but isn't |
Message |
lowerThanMinSize(Object value,
int minSize,
int actualSize)
Generates a
Message for a value that was expected to have
a minimum size but didn't |
Message |
mapIsEmpty()
Generates a
Message for a map
that was expected to be not empty
but was |
Message |
mapIsNotEmpty()
|
Message |
regexDoesNotMatch(String value,
String regex)
|
Message |
stringIsBlank()
Generates a
Message for a string
that was expected to be not blank
but wasn't |
Message |
stringIsNotBlank()
Generates a
Message for a String which was expected
to be blank but wasn't |
Message |
valueIsBlankLiteral()
Generates a
Message for a value that was expected
to not be a BlankLiteral but was |
Message |
valueIsNull()
Generates a
Message for a value that is null
what it wasn't expected to be |
Message |
wasExpectingNull()
Generates a
Message for a value that
was expected to be null but wasn't |
createMessage, createMessage, createMessage, createMessage, createMessage, createStaticMessage, createStaticMessage, getBundlePath, getClassLoader, getReloadControl, getString, getString, getString, getString
public ValidationMessages()
protected ResourceBundle getBundle(String bundlePath)
getBundle
in class MessageFactory
public Message failedBooleanValidation(boolean value, boolean expected)
Message
for a boolean validation that failedvalue
- the value that was obtainedexpected
- the value that was expectedMessage
public Message invalidNumberType(Object value, String numberType)
Message
for a number type validation that failedvalue
- the value that was testednumberType
- the type that the tested value was expected to haveMessage
public Message lowerThan(Object value, Object boundary)
value
that was
expected to be lower than boundary
but isn'tvalue
- the valueboundary
- the boundaryMessage
public Message greaterThan(Object value, Object boundary)
value
that was
expected to be greater than boundary
but isn'tvalue
- the valueboundary
- the boundaryMessage
public Message invalidEmail(String email)
Message
for an email validation
that failedemail
- the validated email addressMessage
public Message invalidIp(String ip)
Message
for an ip address
validation that failedip
- the validated ip addressMessage
public Message lowerThanMinSize(Object value, int minSize, int actualSize)
Message
for a value that was expected to have
a minimum size but didn'tvalue
- the tested valueminSize
- the minimum boundary used in the validationactualSize
- the actual value
sizeMessage
public Message greaterThanMaxSize(Object value, int maxSize, int actualSize)
Message
for a value that was expected to have
a maximum size but didn'tvalue
- the tested valuemaxSize
- the maximum boundary used in the validationactualSize
- the actual value
sizeMessage
public Message valueIsNull()
Message
for a value that is null
what it wasn't expected to beMessage
public Message collectionIsEmpty()
Message
for a value that was
expected to be not empty but wasMessage
public Message stringIsBlank()
Message
for a string
that was expected to be not blank
but wasn'tMessage
public Message mapIsEmpty()
Message
for a map
that was expected to be not empty
but wasMessage
public Message valueIsBlankLiteral()
Message
for a value that was expected
to not be a BlankLiteral
but wasMessage
public Message wasExpectingNull()
Message
for a value that
was expected to be null
but wasn'tMessage
public Message invalidUrl(String url)
Message
for a url
that is not validurl
- the tested urlMessage
public Message regexDoesNotMatch(String value, String regex)
value
- the tested valueregex
- the regex that the value
was tested againstMessage
public Message arrayIsEmpty()
Message
for an array which was expected
to be not empty but wasMessage
public Message stringIsNotBlank()
Message
for a String which was expected
to be blank but wasn'tMessage
public Message collectionIsNotEmpty()
Message
for a Collection
which was expected to be empty but wasn'tMessage
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.