33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using TheCyclopsContracts.Exceptions;
|
|
using TheCyclopsContracts.Extensions;
|
|
using TheCyclopsContracts.Infrastructure;
|
|
|
|
namespace TheCyclopsContracts.DataModels;
|
|
|
|
public class SupplyComponentDataModel(string supplyId, string componentId, int count) : IValidation
|
|
{
|
|
public string SupplyId { get; private set; } = supplyId;
|
|
|
|
public string ComponentId { get; private set; } = componentId;
|
|
|
|
public int Count { get; private set; } = count;
|
|
|
|
public void Validate()
|
|
{
|
|
if (SupplyId.IsEmpty())
|
|
throw new ValidationException("Field SupplyId is empty");
|
|
|
|
if (!SupplyId.IsGuid())
|
|
throw new ValidationException("The value in the field SupplyId is not a unique identifier");
|
|
|
|
if (ComponentId.IsEmpty())
|
|
throw new ValidationException("Field ComponentId is empty");
|
|
|
|
if (!ComponentId.IsGuid())
|
|
throw new ValidationException("The value in the field ComponentId is not a unique identifier");
|
|
|
|
if (Count <= 0)
|
|
throw new ValidationException("Field Count is less than or equal to 0");
|
|
}
|
|
}
|