/*
 * Copyright 2018 Scytl Secure Electronic Voting SA
 *
 * All rights reserved
 *
 * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
 */
package com.scytl.products.ov.commons.validation;

import com.scytl.products.ov.commons.beans.validation.ValidationErrorType;

/**
 * Entity holding the result of a validation.
 */
public class ValidationResult {

	/**
	 * The final result of the validation. If no validation failed, then the result is true. If there are rules that failed,
	 * result is false.
	 */
	private boolean result;

	/**
	 * The validation result code with description of the error or parameters if corresponds.
	 */
	private ValidationError validationError;
	
	public ValidationResult(boolean result) {
		this.result = result;
		if (result) {
			this.validationError = new ValidationError(ValidationErrorType.SUCCESS);
		}
	}

	public ValidationResult() {
	}

	/**
	 * Returns the current value of the field result.
	 *
	 * @return Returns the result.
	 */
	public boolean isResult() {
		return result;
	}

	/**
	 * Sets the value of the field result.
	 *
	 * @param result The result to set.
	 */
	public void setResult(boolean result) {
		this.result = result;
	}

	/**
	 * Returns the current value of the field validationError.
	 *
	 * @return Returns the validationError.
	 */
	public ValidationError getValidationError() {
		return validationError;
	}

	/**
	 * Sets the value of the field validationError.
	 *
	 * @param validationError The validationError to set.
	 */
	public void setValidationError(ValidationError validationError) {
		this.validationError = validationError;
	}

}
