using System;
using System.Collections.Generic;
using System.Linq;
namespace Swan.Validators {
///
/// Defines a validation result containing all validation errors and their properties.
///
public class ObjectValidationResult {
private readonly List _errors = new List();
///
/// A list of errors.
///
public IReadOnlyList Errors => this._errors;
///
/// true if there are no errors; otherwise, false.
///
public Boolean IsValid => !this.Errors.Any();
///
/// Adds an error with a specified property name.
///
/// The property name.
/// The error message.
public void Add(String propertyName, String errorMessage) => this._errors.Add(new ValidationError { ErrorMessage = errorMessage, PropertyName = propertyName });
///
/// Defines a validation error.
///
public class ValidationError {
///
/// The property name.
///
public String PropertyName {
get; internal set;
}
///
/// The message error.
///
public String ErrorMessage {
get; internal set;
}
}
}
}