001// Copyright 2004, 2005 The Apache Software Foundation 002// 003// Licensed under the Apache License, Version 2.0 (the "License"); 004// you may not use this file except in compliance with the License. 005// You may obtain a copy of the License at 006// 007// http://www.apache.org/licenses/LICENSE-2.0 008// 009// Unless required by applicable law or agreed to in writing, software 010// distributed under the License is distributed on an "AS IS" BASIS, 011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012// See the License for the specific language governing permissions and 013// limitations under the License. 014 015package org.apache.tapestry.valid; 016 017import java.util.Locale; 018import java.util.ResourceBundle; 019 020/** 021 * Constants used for accessing validation message patterns. 022 * 023 * @author Paul Ferraro 024 */ 025public final class ValidationStrings 026{ 027 public static final String REQUIRED_FIELD = "field-is-required"; 028 029 public static final String INVALID_DATE = "invalid-date-format"; 030 public static final String INVALID_NUMBER = "invalid-numeric-format"; 031 public static final String INVALID_EMAIL = "invalid-email-format"; 032 033 public static final String REGEX_MISMATCH = "regex-mismatch"; 034 035 public static final String VALUE_TOO_SHORT = "field-too-short"; 036 public static final String VALUE_TOO_LONG = "field-too-long"; 037 038 public static final String VALUE_TOO_SMALL = "number-too-small"; 039 public static final String VALUE_TOO_LARGE = "number-too-large"; 040 041 public static final String DATE_TOO_EARLY = "date-too-early"; 042 public static final String DATE_TOO_LATE = "date-too-late"; 043 044 public static final String INVALID_FIELD_EQUALITY = "invalid-field-equality"; 045 046 private static final String RESOURCE_BUNDLE = ValidationStrings.class.getName(); 047 048 /** 049 * Fetches the appropriate validation message pattern from the appropriate localized resource. 050 * This method should be called with the locale of the current request. 051 */ 052 public static String getMessagePattern(String key, Locale locale) 053 { 054 return ResourceBundle.getBundle(RESOURCE_BUNDLE, locale).getString(key); 055 } 056 057 private ValidationStrings() 058 { 059 // Disable construction 060 } 061}