// <auto-generated>
// DO NOT EDIT: generated by fsdgencsharp
// </auto-generated>
using System;
using System.Collections.Generic;
using Facility.Core;

namespace OapApi.v1.Client
{
	[System.CodeDom.Compiler.GeneratedCode("fsdgencsharp", "")]
	public sealed partial class ApplicationCreateSetDto : ServiceDto<ApplicationCreateSetDto>
	{
		/// <summary>
		/// Creates an instance.
		/// </summary>
		public ApplicationCreateSetDto()
		{
		}

		/// <summary>
		/// Terms a user must accept to start an application.
		/// </summary>
		public ApplicationTermsCreateSetDto Terms { get; set; }

		/// <summary>
		/// The JSON serializer.
		/// </summary>
		protected override JsonServiceSerializer JsonSerializer => SystemTextJsonServiceSerializer.Instance;

		/// <summary>
		/// Determines if two DTOs are equivalent.
		/// </summary>
		public override bool IsEquivalentTo(ApplicationCreateSetDto other)
		{
			return other != null &&
				ServiceDataUtility.AreEquivalentDtos(Terms, other.Terms);
		}

		/// <summary>
		/// Validates the DTO.
		/// </summary>
		public override bool Validate(out string errorMessage)
		{
			errorMessage = GetValidationErrorMessage();
			return errorMessage == null;
		}

		private string GetValidationErrorMessage()
		{
			if (Terms == null)
				return ServiceDataUtility.GetRequiredFieldErrorMessage("terms");

			string errorMessage;
			if (!ServiceDataUtility.ValidateFieldValue(Terms, "terms", out errorMessage))
				return errorMessage;

			return null;
		}
	}
}
