using System.Collections.ObjectModel;
using Microsoft.AspNetCore.Mvc.ModelBinding;

namespace DiplomovaPrace.Web.Server.Infrastructure.ModelValidation
{
	public class ValidationResultModel
	{
		public int StatusCode { get; }

		public ReadOnlyCollection<FieldValidationError> Errors { get; }

		public ValidationResultModel(int statusCode, ModelStateDictionary modelState)
		{
			StatusCode = statusCode;
			Errors = FieldValidationError.FromModelState(modelState);
		}

		public static object FromModelState(int statusCode, ModelStateDictionary modelState)
		{
			return new ValidationResultModel(statusCode, modelState);
		}
	}
}
