Ejemplo n.º 1
0
        /// <summary>
        /// Validatethe data type returning the validation errors that occurred
        /// </summary>
        public override IEnumerable <Connectors.IResultDetail> ValidateEx()
        {
            var retVal = new List <IResultDetail>(base.ValidateEx());

            if (!((this.Data != null) ^ (this.Reference != null)))
            {
                retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Warning, "ED", "The Data and Reference properties should be used exclusive of each other", null));
            }
            if (this.NullFlavor != null && (this.Data != null || this.Reference != null))
            {
                retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ED", ValidationMessages.MSG_NULLFLAVOR_WITH_VALUE));
            }
            else if (this.NullFlavor == null && this.Data == null && this.Reference == null)
            {
                retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ED", ValidationMessages.MSG_NULLFLAVOR_MISSING));
            }
            if (this.Translation != null && this.Translation.FindAll(o => o.Translation != null).Count > 0)
            {
                retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ED", String.Format(EverestFrameworkContext.CurrentCulture, ValidationMessages.MSG_PROPERTY_NOT_PERMITTED_ON_PROPERTY, "Translation", "Translation"), null));
            }
            if (this.Reference != null && !TEL.IsValidUrlFlavor(this.Reference))
            {
                retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ED", "When populated, Reference must be a valid instance of TEL.URL", null));
            }
            if (this.Thumbnail != null && this.Thumbnail.Thumbnail != null)
            {
                retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ED", String.Format(EverestFrameworkContext.CurrentCulture, ValidationMessages.MSG_PROPERTY_NOT_PERMITTED_ON_PROPERTY, "Thumbnail", "Thumbnail"), null));
            }
            if (this.Thumbnail != null && this.Thumbnail.Reference != null)
            {
                retVal.Add(new DatatypeValidationResultDetail(ResultDetailType.Error, "ED", String.Format(EverestFrameworkContext.CurrentCulture, ValidationMessages.MSG_PROPERTY_NOT_PERMITTED_ON_PROPERTY, "Thumbnail", "Reference"), null));
            }

            return(retVal);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Validate ED
 /// </summary>
 /// <remarks>
 /// An ED is valid if
 /// <list type="bullet">
 ///     <item>Data is set, XOR</item>
 ///     <item>NullFlavor is provided</item>
 /// </list>
 /// </remarks>
 public override bool Validate()
 {
     return(((((this.Data != null) ^ (this.Reference != null))) ^ (this.NullFlavor != null)) &&
            (((this.Data != null || this.Reference != null)) || (this.Data == null && this.Reference == null)) &&
            (this.Translation != null && this.Translation.FindAll(o => o.Translation == null).Count == this.Translation.Count ||
             this.Translation == null) &&
            (this.Reference == null || TEL.IsValidUrlFlavor(this.Reference)) &&
            (this.Thumbnail == null || this.Thumbnail.Thumbnail == null && this.Thumbnail.Reference == null));
 }