001// Copyright 2010, 2012 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007// http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry5.validator;
016
017import org.apache.tapestry5.Field;
018import org.apache.tapestry5.MarkupWriter;
019import org.apache.tapestry5.ValidationException;
020import org.apache.tapestry5.commons.MessageFormatter;
021import org.apache.tapestry5.services.FormSupport;
022
023/**
024 * The none validator is does nothing on either the client or the server; primarily it is employed
025 * as the validate parameter, to override the validation specified in the {@link org.apache.tapestry5.beaneditor.Validate}
026 * annotation of a property.
027 */
028public class None extends AbstractValidator<Void, Object>
029{
030    public None()
031    {
032        // It is inefficient if there is not a valid matching message key even though the implementation does nothing.
033        // Previous releases used "required" here but that's confusing. The "private-" prefix keeps this from being
034        // sent to the client (every byte counts!).
035        super(null, Object.class, "private-no-validation-for-field", null);
036    }
037
038    /**
039     * Does nothing.
040     */
041    public void render(Field field, Void constraintValue, MessageFormatter formatter, MarkupWriter writer,
042                       FormSupport formSupport)
043    {
044    }
045
046    /**
047     * Does nothing.
048     */
049    public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value)
050            throws ValidationException
051    {
052    }
053}