using System.ComponentModel.DataAnnotations.Schema;
using Claim = System.Security.Claims.Claim;

namespace OpenWarehouse.warehouse.api.Data;

public class ServiceClaims
{
    [Key, Required, MinLength(3), MaxLength(40)]
    public string? ClaimType { get; set; }
    [Required, MinLength(3), MaxLength(40)]
    public string? ClaimValue { get; set; }

    [NotMapped]
    public Claim Claim
    {
        get =>
            new(ClaimType ?? 
                throw new InvalidOperationException(),
                ClaimValue ?? throw new InvalidOperationException());
        set
        {
            ClaimType = value.Type;
            ClaimValue = value.Value;
        }
    }
}