001package gwt.material.design.client.base.validator; 002 003import gwt.material.design.client.base.validator.ValidationChangedEvent.HasValidationChangedHandlers; 004 005/* 006 * #%L 007 * GwtBootstrap3 008 * %% 009 * Copyright (C) 2015 GwtBootstrap3 010 * %% 011 * Licensed under the Apache License, Version 2.0 (the "License"); 012 * you may not use this file except in compliance with the License. 013 * You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, software 018 * distributed under the License is distributed on an "AS IS" BASIS, 019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 020 * See the License for the specific language governing permissions and 021 * limitations under the License. 022 * #L% 023 */ 024 025/** 026 * Should use when implementing classes with {@link Validator}s. 027 * 028 * @param <T> the generic type 029 * @author Steven Jardine 030 */ 031public interface HasValidators<T> extends HasValidationChangedHandlers { 032 033 /** 034 * Adds the validator. 035 * 036 * @param validator the validator 037 */ 038 void addValidator(Validator<T> validator); 039 040 /** 041 * Gets the validate on blur. 042 * 043 * @return the validate on blur 044 */ 045 boolean isValidateOnBlur(); 046 047 /** 048 * Removes the validator. 049 * 050 * @param validator the validator 051 * @return true, if successful 052 */ 053 boolean removeValidator(Validator<T> validator); 054 055 /** 056 * Reset the form element to blank and clear error messages. 057 */ 058 void reset(); 059 060 /** 061 * Sets the validate on blur. 062 * 063 * @param validateOnBlur the new validate on blur 064 */ 065 void setValidateOnBlur(boolean validateOnBlur); 066 067 /** 068 * The validators used to validate this object. 069 * 070 * @param validators the new validators 071 */ 072 void setValidators(@SuppressWarnings("unchecked") Validator<T>... validators); 073 074 /** 075 * Validate the field's value using the supplied validators. 076 * 077 * @return true, if valid 078 */ 079 boolean validate(); 080 081 /** 082 * Validate the field's value using the supplied validators. 083 * 084 * @param show the error to the user. 085 * @return true, if valid 086 */ 087 boolean validate(boolean show); 088 089}