org.mule.runtime.api.el.ValidationResult Maven / Gradle / Ivy
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.runtime.api.el;
import org.mule.runtime.api.el.validation.ValidationMessage;
import java.util.List;
import java.util.Optional;
/**
* Represents the result of an expression validation.
*
* @since 1.0
*/
public interface ValidationResult {
static ValidationResult success() {
return new DefaultValidationResult(true, null);
}
static ValidationResult failure(String message) {
return new DefaultValidationResult(false, message);
}
static ValidationResult failure(String message, List messages) {
return new DefaultValidationResult(false, message, messages);
}
static ValidationResult failure(String message, String expression) {
return failure(String.format("%s. Offending expression string is: %s", message, expression));
}
/**
* @return an optional representing the generic validation error or an empty one
*/
Optional errorMessage();
/**
* @return a list of all {@link ValidationMessage}s found or an empty list if no relevant data is present
*/
List messages();
/**
* @return true if the validation was ok, false otherwise
*/
boolean isSuccess();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy