private static String normalizeSubject(final String msgSubject) { if (msgSubject.isEmpty() || "/".equals(msgSubject)) { throw SubjectInvalidException.newBuilder(msgSubject).build(); } return msgSubject.charAt(0) == '/' ? msgSubject.substring(1) : msgSubject; }
@Override public void validateValue(@Nullable final CharSequence value) { super.validateValue(value); final Validator subjectValidator = IdValidator.newInstance(value, SUBJECT_REGEX); if (!subjectValidator.isValid()) { final String msgTemplate = "The subject <{0}> is invalid because it did not match the pattern <{1}>!"; throw SubjectInvalidException.newBuilder(String.valueOf(value)) .message(() -> MessageFormat.format(msgTemplate, value, SUBJECT_REGEX)) .build(); } } },