1 /* 2 * Copyright 2004-2009 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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 org.springmodules.validation.commons; 18 19 import java.util.Locale; 20 21 import org.apache.commons.validator.Validator; 22 import org.apache.commons.validator.ValidatorResources; 23 import org.springframework.validation.Errors; 24 25 /** 26 * @author Daniel Miller 27 */ 28 public interface ValidatorFactory { 29 30 /** 31 * Gets a new instance of a validator for the given bean (form). 32 * 33 * @param beanName The name of the bean for which this validator will be created. 34 */ 35 public Validator getValidator(String beanName, Object bean, Errors errors); 36 37 /** 38 * Returns true if this validator factory can create a validator that 39 * supports the given <code>beanName</code> and <code>locale</code>. 40 * 41 * @param beanName String name of the bean to be validated. 42 * @param locale Locale of the validator to create. 43 * @return true if this validator factory can create a validator for the 44 * given bean name. 45 */ 46 public boolean hasRulesForBean(String beanName, Locale locale); 47 48 /** 49 * @return Returns the validatorResources. 50 */ 51 public ValidatorResources getValidatorResources(); 52 }