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 com.google.gwt.editor.client.Editor; 023import com.google.gwt.editor.client.EditorError; 024 025import java.util.List; 026 027/** 028 * An input validator. 029 * 030 * @param <T> the type. 031 * @author Steven Jardine 032 */ 033public interface Validator<T> { 034 035 /** 036 * Represents the priority of a validator. 037 */ 038 public static class Priority { 039 040 /** 041 * HIGHEST priority 042 */ 043 public static final int HIGHEST = 0; 044 045 /** 046 * HIGH priority 047 */ 048 public static final int HIGH = 25; 049 050 /** 051 * MEDIUM priority 052 */ 053 public static final int MEDIUM = 50; 054 055 /** 056 * LOW priority 057 */ 058 public static final int LOW = 75; 059 060 /** 061 * LOWEST priority 062 */ 063 public static final int LOWEST = 100; 064 065 } 066 067 /** 068 * Priority value for this validator. Lower the number, higher the priority. 069 * 070 * @return the priority. 071 */ 072 int getPriority(); 073 074 /** 075 * Validate the field. 076 * 077 * @param editor the {@link Editor}. 078 * @param value the value 079 * @return the list 080 */ 081 List<EditorError> validate(Editor<T> editor, T value); 082}