/** * Copyright (C) 2015 Valkyrie RCP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.valkyriercp.binding.form; import org.valkyriercp.binding.validation.ValidationMessage; import org.valkyriercp.binding.validation.ValidationResultsModel; import org.valkyriercp.binding.validation.Validator; /** * Sub-interface implemented by form models that can validate its own * properties. * * @author Keith Donald * @author Oliver Hutchison */ public interface ValidatingFormModel extends ConfigurableFormModel, HierarchicalFormModel { public static final String VALIDATING_PROPERTY = "validating"; /** * Returns the ValidationResultsModel which encapsulates the set of * validation messages currently active against this form model. Will be * empty if validation is disabled. */ ValidationResultsModel getValidationResults(); /** * Does this ValidatingFormModel or any of its children contain errors? */ boolean getHasErrors(); /** * Is this form model currently validating? */ boolean isValidating(); /** * Sets whether or not validation is currently enabled for this form model. * If validation is enabled the form model will immediately validate all * form properties. If validation is disabled all validation messages held * by the ValidationResultsModel will be cleared. */ void setValidating(boolean validating); /** * Forces the form model to validate its self. If validation is disabled it * does nothing. */ void validate(); /** * Get the validator that will be used to validate the form model. */ Validator getValidator(); /** * Set the validator that will be used to validate the form model. */ void setValidator(Validator validator); /** * Provide validation messages that are generated by a process separate from * the standard Validator. * <p> * All error messages that are raised using this method must be cleared * using the method {@link #clearValidationMessage(ValidationMessage)} before * the form model can be commited. * * @param validationMessage the message to raise */ void raiseValidationMessage(ValidationMessage validationMessage); /** * Clear validation messages that are generated by a process separate from * the standard Validator. * * @param validationMessage the message to clear */ void clearValidationMessage(ValidationMessage validationMessage); }