pathTokens.add(getDescription().getName()); String keyConstraint = StringUtils.join(pathTokens, '.'); String computedInvalidValue = "null"; String message = getMessageString(MESSAGES_BUNDLE, keyConstraint, params, computedLocale); params = new Object[] { computedInvalidValue, toString() }; message = getMessageString(MESSAGES_BUNDLE, MESSAGES_KEY, params, computedLocale); if (message != null && !message.trim().isEmpty() && !keyConstraint.equals(message)) { } else { return String.format(HARD_CODED_CONTRAINT_ERROR_MESSAGE, toString(), computedInvalidValue);
@Override public String getErrorMessage(Object invalidValue, Locale locale) { // test whether there's a custom translation for this field constraint specific translation // the expected key is label.schema.constraint.violation.[ConstraintName] // follow the AbstractConstraint behavior otherwise List<String> pathTokens = new ArrayList<>(); pathTokens.add(MESSAGES_KEY); pathTokens.add(EnumConstraint.NAME); String key = StringUtils.join(pathTokens, '.'); Object[] params = new Object[] { StringUtils.join(getPossibleValues(), ", ") }; Locale computedLocale = locale != null ? locale : Constraint.MESSAGES_DEFAULT_LANG; String message = getMessageString(MESSAGES_BUNDLE, key, params, computedLocale); if (message != null && !message.trim().isEmpty() && !key.equals(message)) { // use a custom constraint message if there's one return message; } else { // follow AbstractConstraint behavior otherwise return super.getErrorMessage(invalidValue, computedLocale); } }
@Override public final String toString() { return getDescription().toString(); }
@Override public String getErrorMessage(Object invalidValue, Locale locale) { // test whether there's a custom translation for this field constraint specific translation // the expected key is label.schema.constraint.violation.[ConstraintName] // follow the AbstractConstraint behavior otherwise List<String> pathTokens = new ArrayList<String>(); pathTokens.add(MESSAGES_KEY); pathTokens.add(PatternConstraint.NAME); String key = StringUtils.join(pathTokens, '.'); Object[] params = new Object[] { getPattern() }; Locale computedLocale = locale != null ? locale : Constraint.MESSAGES_DEFAULT_LANG; String message = getMessageString(MESSAGES_BUNDLE, key, params, computedLocale); if (message != null && !message.trim().isEmpty() && !key.equals(message)) { // use a custom constraint message if there's one return message; } else { // follow AbstractConstraint behavior otherwise return super.getErrorMessage(invalidValue, computedLocale); } }
} else { return super.getErrorMessage(invalidValue, computedLocale);
} else { return super.getErrorMessage(invalidValue, computedLocale);
} else { return super.getErrorMessage(invalidValue, computedLocale);