// model is basically not correct, so don't validate kz83 value static Lst <KzFieldError> ValidateKz83(KzFieldSet fieldSet, int fieldNumber) => fieldSet.GetValue(fieldNumber).Map(x => x.GetDecimalValue()) .Map(fieldValue => CalculateKz83(fieldSet) .Apply( estimatedValue => Math.Abs(fieldValue - estimatedValue.Value) > 0.01m ? List(KzFieldError.MustBeCloseToValue(estimatedValue.Value, 0.01m)) : Lst <KzFieldError> .Empty)) .IfNone(Lst <KzFieldError> .Empty);
public Kz83Calculator(KzFieldSet fieldSet) { this.fieldSet = fieldSet ?? throw new ArgumentNullException(nameof(fieldSet)); }
static Money CalculateKz83(KzFieldSet fieldSet) => new Kz83Calculator(fieldSet) .Calculate().IfFail(_ => throw new InvalidOperationException("Can't happen"));
UstvaKzFields(KzFieldSet fieldSet) { this.FieldSet = fieldSet; }