From 9ffbd23cb7ccecd8866cc5e5cdd3c01e6ca92a30 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 6 Apr 2023 12:30:16 +0200 Subject: [PATCH] fixed validation even with some missing strings in the database --- ENI2/ENI2.csproj | 2 +- bsmd.database/HAZ.cs | 1 + bsmd.database/IGCPosition.cs | 5 ++--- bsmd.database/IMDGPosition.cs | 2 +- bsmd.database/IMSBCPosition.cs | 12 ++++++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj index 544d357d..32623fcf 100644 --- a/ENI2/ENI2.csproj +++ b/ENI2/ENI2.csproj @@ -36,7 +36,7 @@ 5.4.0.0 true publish.html - 2 + 3 7.11.0.%2a false true diff --git a/bsmd.database/HAZ.cs b/bsmd.database/HAZ.cs index a0755f50..eb3d1551 100644 --- a/bsmd.database/HAZ.cs +++ b/bsmd.database/HAZ.cs @@ -543,6 +543,7 @@ namespace bsmd.database foreach(IGCPosition igc in this.IGCPositions) { RuleEngine.ValidateProperties(igc, errors, violations); + igc.Validate(errors, violations); } foreach(IMSBCPosition imsbc in this.IMSBCPositions) diff --git a/bsmd.database/IGCPosition.cs b/bsmd.database/IGCPosition.cs index b0b5a354..ac739e49 100644 --- a/bsmd.database/IGCPosition.cs +++ b/bsmd.database/IGCPosition.cs @@ -203,11 +203,10 @@ namespace bsmd.database { if (!this.UNNumber.IsNullOrEmpty() && !unNumberRegex.IsMatch(this.UNNumber)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "UNNumber", this.UNNumber, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "UNNumber", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); if (!this.IMOClass.IsNullOrEmpty() && !imoClassRegex.IsMatch(this.IMOClass)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "IMOClass", this.IMOClass, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); - + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "IMOClass", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); } #endregion diff --git a/bsmd.database/IMDGPosition.cs b/bsmd.database/IMDGPosition.cs index fbe1836e..76764811 100644 --- a/bsmd.database/IMDGPosition.cs +++ b/bsmd.database/IMDGPosition.cs @@ -31,7 +31,7 @@ namespace bsmd.database #region static Regex private static Regex imoClassRegex = new Regex(@"^[1-9]{1}(\.[1-9]{1}([A-Z]{1})?)?$"); - private static Regex unNumberRegex = new Regex(@"^[0 - 9]{4}$"); + private static Regex unNumberRegex = new Regex(@"^[0-9]{4}$"); #endregion diff --git a/bsmd.database/IMSBCPosition.cs b/bsmd.database/IMSBCPosition.cs index 5b5098eb..608174c7 100644 --- a/bsmd.database/IMSBCPosition.cs +++ b/bsmd.database/IMSBCPosition.cs @@ -238,19 +238,23 @@ namespace bsmd.database { if(!MHB ?? false) { - if(this.UNNumber.IsNullOrEmpty() || !unNumberRegex.IsMatch(this.UNNumber)) + if(this.UNNumber.IsNullOrEmpty()) violations.Add(RuleEngine.CreateViolation(ValidationCode.V803, "UNNumber", this.UNNumber, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); - if (this.IMOClass.IsNullOrEmpty() || !imoClassRegex.IsMatch(this.IMOClass)) + if (this.IMOClass.IsNullOrEmpty()) violations.Add(RuleEngine.CreateViolation(ValidationCode.V803, "IMOClass", this.IMOClass, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); } - + + if(!this.UNNumber.IsNullOrEmpty() && !unNumberRegex.IsMatch(this.UNNumber)) + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "UNNumber", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); + + if(!this.IMOClass.IsNullOrEmpty() && !imoClassRegex.IsMatch(this.IMOClass)) + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "IMOClass", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); if (!this.IMOHazardClass.HasValue) { violations.Add(RuleEngine.CreateViolation(ValidationCode.V810, "Hazards", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); } - } #endregion