stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace StellaOps.PolicyAuthoritySignals.Contracts;
|
||||
|
||||
public sealed record PolicyContract
|
||||
{
|
||||
private string _policyId = string.Empty;
|
||||
|
||||
[JsonPropertyName("policyId")]
|
||||
public string PolicyId
|
||||
{
|
||||
get => _policyId;
|
||||
init => _policyId = RequireNonEmpty(value, nameof(PolicyId));
|
||||
}
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; init; } = "0.1-draft";
|
||||
|
||||
[JsonPropertyName("rulesHash")]
|
||||
public string? RulesHash { get; init; }
|
||||
|
||||
public PolicyContract(string policyId, string? version = null, string? rulesHash = null)
|
||||
{
|
||||
PolicyId = policyId;
|
||||
if (!string.IsNullOrWhiteSpace(version))
|
||||
{
|
||||
Version = version;
|
||||
}
|
||||
|
||||
RulesHash = rulesHash;
|
||||
}
|
||||
|
||||
private static string RequireNonEmpty(string value, string paramName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new ArgumentException("Value cannot be null or whitespace.", paramName);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user