/// <summary> /// Validate the data type and return the validation errors detected /// </summary> public override IEnumerable <IResultDetail> ValidateEx() { List <IResultDetail> retVal = new List <IResultDetail>(base.ValidateEx()); if (this.Offset != null) { if (this.Offset.Low != null && !this.Offset.Low.IsNull && !PQ.IsValidTimeFlavor(this.Offset.Low)) { retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "EIVL", "When populated, the Offset.Low property must contain a valid PQ.TIME instance", null)); } if (this.Offset.High != null && !this.Offset.High.IsNull && !PQ.IsValidTimeFlavor(this.Offset.High)) { retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "EIVL", "When populated, the Offset.High property must contain a valid PQ.TIME instance", null)); } if (this.Offset.Width != null && !this.Offset.Width.IsNull && !PQ.IsValidTimeFlavor(this.Offset.Width)) { retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "EIVL", "When populated, the Offset.Width property must contain a valid PQ.TIME instance", null)); } if (this.Offset.Value != null && !this.Offset.Value.IsNull && !PQ.IsValidTimeFlavor(this.Offset.Value)) { retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "EIVL", "When populated, the Offset.Value property must contain a valid PQ.TIME instance", null)); } } string cc = Util.ToWireFormat(this.Event); if (!((cc.StartsWith("IC") || cc.StartsWith("AC") || cc.StartsWith("PC")) ^ (this.Offset != null))) { retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "EIVL", "When the Event property implies before, after or between meals the Offset property must not be populated", null)); } return(retVal); }
/// <summary> /// Validate this EIVL /// </summary> public override bool Validate() { bool valid = (NullFlavor != null) ^ (Offset != null || Event != null); if (this.Offset != null) { valid &= this.Offset.Low == null || this.Offset.Low.IsNull || PQ.IsValidTimeFlavor(this.Offset.Low); valid &= this.Offset.High == null || this.Offset.High.IsNull || PQ.IsValidTimeFlavor(this.Offset.High); valid &= this.Offset.Width == null || this.Offset.Width.IsNull || PQ.IsValidTimeFlavor(this.Offset.Width); valid &= this.Offset.Value == null || this.Offset.Value.IsNull || PQ.IsValidTimeFlavor(this.Offset.Value); } string cc = Util.ToWireFormat(this.Event); valid &= (cc.StartsWith("IC") || cc.StartsWith("AC") || cc.StartsWith("PC")) ^ (this.Offset != null); return(valid); }
/// <summary> /// Validates that this TS meets the basic validation criteria /// </summary> /// <remarks> /// <para>Basic validation criteria is considered:</para> /// <list type="bullet"> /// <item><description>If <see cref="P:NullFlavor"/> is not null, then <see cref="P:DateValue"/> and <see cref="P:UncertainRange"/> cannot be set</description></item> /// <item><description>If <see cref="P:DateValue"/> or <see cref="P:UncertainRange"/> are populated, then <see cref="P:NullFlavor"/> cannot be set</description></item> /// <item><description>Both <see cref="P:DateValue"/> and <see cref="P:UncertainRange"/> cannot be set at the same time</description></item> /// <item><description>Any uncertainty (<see cref="P:Uncertainty"/>, or <see cref="P:UncertainRange"/>) must contain valid <see cref="T:PQ"/>.TIME or <see cref="T:IVL`1"/>of PQ.TIME</description></item> /// </list> /// </remarks> public override bool Validate() { return((NullFlavor != null) ^ ((DateValue != default(DateTime) || UncertainRange != null) && ((this.Uncertainty != null && this.Uncertainty is PQ && PQ.IsValidTimeFlavor(this.Uncertainty as PQ)) || (this.Uncertainty == null)) && ((this.UncertainRange != null && this.UncertainRange.Low is PQ && this.UncertainRange.High is PQ && PQ.IsValidTimeFlavor(this.UncertainRange.Low as PQ) && PQ.IsValidTimeFlavor(this.UncertainRange.High as PQ)) || this.UncertainRange == null) && (((DateValue != default(DateTime)) ^ (this.UncertainRange != null)) || (this.DateValue == null && this.UncertainRange == null)))); }