01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package info.jtrac.util;
18:
19: /**
20: * Helper class that improves on the Spring ValidationUtils
21: * for inserting error messages for form object fields
22: * into the view "errors" object
23: */
24: public class ValidationUtils {
25:
26: public static boolean isAllUpperCase(String input) {
27: if (input == null) {
28: return false;
29: }
30: return input.matches("[A-Z0-9]+");
31: }
32:
33: public static boolean isValidLoginName(String input) {
34: if (input == null) {
35: return false;
36: }
37: return input.matches("[\\w.@\\\\-]+");
38: }
39:
40: /**
41: * Only letters are allowed, not even numbers
42: * and CamelCase with dash as word separator
43: */
44: public static boolean isCamelDashCase(String input) {
45: if (input == null) {
46: return false;
47: }
48: return input.matches("[A-Z][a-z]+(-[A-Z][a-z]+)*");
49: }
50:
51: }
|