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