﻿using System.Collections.Generic;
using System.Reflection;

namespace appfactum.core
{
    /// <summary>
    /// Interface for classes that support advanced validation.
    /// 
    /// Classes that implement this interface support a Validate 
    /// method in which they can perform all types of validations 
    /// for all data they contain. For example, the BindingConnector 
    /// calls these advanced Validate methods when the Validate method 
    /// of the BindingConnector is called and supports the DataSource 
    /// IValidatable.
    /// </summary>
    public interface IValidatable
    {
        /// <summary>
        /// Validate data 
        /// </summary>
        /// <param name="messages">Dictionary withd messages which provide informations about the invalid data. 
        /// Add entrys where key is the name of the property that contains invalid data and value is a message which describing this problem to this dictionary.</param>
        /// <returns>return true if object is valid, otherwise false</returns>
        bool Validate(ref IDictionary<string, string> messages);

        /// <summary>
        /// Validate data 
        /// </summary>
        /// <param name="messages">Dictionary withd messages which provide informations about the invalid data. 
        /// Add tuples with 1. name of the property that contains invalid data and 2. message describing this problem to this list.</param>
        /// <param name="properties">List of properties to be checked if this list is null or empty, all properties will be validated.</param>
        /// <returns>return true if object is valid, otherwise false</returns>
        bool Validate(ref IDictionary<string, string> messages, IEnumerable<PropertyDescription> properties);
    }
}
