package nl.quintor.commons.util; import java.util.HashMap; import java.util.Map; public final class ValidatorMessages { public static final String VALIDATIONERROR_POSTALCODE_INVALID = "validationerror.postal.invalid"; public static final String VALIDATIONERROR_POSTALCODE_UNAVAILABLE = "validationerror.postal.unavailable"; public static final String VALIDATIONERROR_BIRTHDATE_UNAVAILABLE = "validationerror.birthdate.unavailable"; public static final String VALIDATIONERROR_BIRTHDATE_INFUTURE = "validationerror.birthdate.infuture"; public static final String VALIDATIONERROR_BIRTHDATE_TOOOLD = "validationerror.birthdate.tooold"; public static final String VALIDATIONERROR_BIRTHDATE_TOOYOUNG = "validationerror.birthdate.tooyoung"; /** * List with default messages used for validation errors. These can be used for example when there is no message * resource bundle available to the application. */ static final Map defaultMessages; static { // set default error messages defaultMessages = new HashMap(); defaultMessages.put(VALIDATIONERROR_POSTALCODE_INVALID, "Postalcode exists of 4 numbers, 2 characters and not below 1000"); defaultMessages.put(VALIDATIONERROR_POSTALCODE_UNAVAILABLE, "Postalcode is not available"); defaultMessages.put(VALIDATIONERROR_BIRTHDATE_UNAVAILABLE, "Birthdate is not available"); defaultMessages.put(VALIDATIONERROR_BIRTHDATE_INFUTURE, "Birthdat can't be in the future"); defaultMessages.put(VALIDATIONERROR_BIRTHDATE_TOOOLD, "Maximum %s years of age allowed"); defaultMessages.put(VALIDATIONERROR_BIRTHDATE_TOOYOUNG, "Minimum %s years of age allowed"); } /** * Private constructor; This class is not meant to be instantiated. This is a utility class with static methods * only. */ private ValidatorMessages() { // } /** * @return The default message for a given error code. */ public static final String getDefaultMessage(final String errorCode) { return defaultMessages.get(errorCode); } }