001package org.gwtbootstrap3.client.ui.form.validator; 002 003import org.gwtbootstrap3.client.ui.form.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 getValidateOnBlur(); 046 047 048 /** 049 * Removes the validator. 050 * 051 * @param validator the validator 052 * @return true, if successful 053 */ 054 boolean removeValidator(Validator<T> validator); 055 056 /** 057 * Reset the form element to blank and clear error messages. 058 */ 059 void reset(); 060 061 /** 062 * Sets the validate on blur. 063 * 064 * @param validateOnBlur the new validate on blur 065 */ 066 void setValidateOnBlur(boolean validateOnBlur); 067 068 /** 069 * The validators used to validate this object. 070 * 071 * @param validators the new validators 072 */ 073 void setValidators(@SuppressWarnings("unchecked") Validator<T>... validators); 074 075 /** 076 * Validate the field's value using the supplied validators. 077 * 078 * @return true, if valid 079 */ 080 boolean validate(); 081 082 /** 083 * Validate the field's value using the supplied validators. 084 * 085 * @param show the error to the user. 086 * @return true, if valid 087 */ 088 boolean validate(boolean show); 089 090}